Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when readStream on IOS #356

Open
tsogzark opened this issue May 3, 2024 · 2 comments
Open

Crash when readStream on IOS #356

tsogzark opened this issue May 3, 2024 · 2 comments

Comments

@tsogzark
Copy link

tsogzark commented May 3, 2024

Reproduce

I met the issue when i use this function to read a 300MB file on ios and when I read a 3MB it works well.
It works well on android when read 300MB file, too.

   public splitLargeFile = async (localPath: string) => {
        let chunkCount = 0;
        const basename = localPath.split('/').pop();
        const bufferSize = 1024 * 900;
        RNFetchBlob.fs.readStream(
            localPath,
            'base64',
            bufferSize
        )
        .then((ifstream) => {
            ifstream.open();
            ifstream.onData(chunk => {
                chunkCount += 1;
                console.log(`${basename} chunk ${chunkCount*bufferSize}`);
            });
           ifstream.onError(err => {
                console.log('oops', err)
            });
            ifstream.onEnd(() => {
                console.log("End")
            });
        })
    }

Error

 LOG  2afae907f0696430905e416aca57f2ce.MP4 chunk 157593600
 LOG  2afae907f0696430905e416aca57f2ce.MP4 chunk 158515200
 LOG  oops [Error: Failed to convert data to 'base64' encoded string, this might due to the source data is not able to convert using this encoding. source = Failed to grow buffer]
 WARN  Failed to convert data to 'base64' encoded string, this might due to the source data is not able to convert using this encoding. source = Failed to grow buffer
 WARN  Failed to convert data to 'base64' encoded string, this might due to the source data is not able to convert using this encoding. source = Failed to grow buffer

log source

NSString * message = [NSString stringWithFormat:@"Failed to convert data to '%@' encoded string, this might due to the source data is not able to convert using this encoding. source = %@", encoding, [ex description]];

@ivaniuk7531
Copy link

I have the same error. @tsogzark, did you fix it?

@tsogzark
Copy link
Author

I have the same error. @tsogzark, did you fix it?

I split the file into smaller chunks for transmission.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants