itinance / itinance/react-native-fs

[Android] uploadFiles progress is inaccurate when binaryStreamOnly is set

Open
#1,129 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
5k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

On Android, when `binaryStreamOnly` is set to `true`, progress updates record an inaccurate number for `totalBytesSent`. Specifically, according to progress updates, `totalBytesSent` is equal `totalBytesExpectedToSend` long before the files are actually uploaded and the upload promise resolves. Depending on internet speed, several minutes can pass between the final progress update and the upload actually completing.

Representative code:
```
const uploader = RNFS.uploadFiles({
toUrl: uploadUrl,
method: 'PUT',
binaryStreamOnly: true,
files: [
{
name: 'currentUpload.zip',
filename: 'currentUpload.zip',
filepath: zipPath,
filetype: 'zip',
},
],
progress: (progress) => {
// progress.totalBytesSent equals progress.totalBytesExpectedToSend long before uploader.promise resolves (sometime minutes)
setProgress(
(progress.totalBytesSent / progress.totalBytesExpectedToSend),
);
},
});

// Wait for the upload to finish
const uploadResponse = await uploader.promise;
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.