Skip to content

Commit

Permalink
Fixed truncating of progress report values.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamburnett committed Jul 16, 2018
1 parent fb0c5f1 commit 5094579
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions android/src/main/java/com/RNFetchBlob/RNFetchBlobBody.java
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private File createMultipartBodyCache() throws IOException {
*/
private void pipeStreamToSink(InputStream stream, BufferedSink sink) throws IOException {
byte[] chunk = new byte[10240];
int totalWritten = 0;
long totalWritten = 0;
int read;
while((read = stream.read(chunk, 0, 10240)) > 0) {
sink.write(chunk, 0, read);
Expand Down Expand Up @@ -403,7 +403,7 @@ private class FormField {
* Emit progress event
* @param written Integer
*/
private void emitUploadProgress(int written) {
private void emitUploadProgress(long written) {
RNFetchBlobProgressConfig config = RNFetchBlobReq.getReportUploadProgress(mTaskId);
if(config != null && contentLength != 0 && config.shouldReport((float)written/contentLength)) {
WritableMap args = Arguments.createMap();
Expand Down
4 changes: 2 additions & 2 deletions ios/RNFetchBlobRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ - (void) URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dat
sendDeviceEventWithName:EVENT_PROGRESS
body:@{
@"taskId": taskId,
@"written": [NSString stringWithFormat:@"%ld", (long) receivedBytes],
@"total": [NSString stringWithFormat:@"%ld", (long) expectedBytes],
@"written": [NSString stringWithFormat:@"%lld", (long long) receivedBytes],
@"total": [NSString stringWithFormat:@"%lld", (long long) expectedBytes],
@"chunk": chunkString
}
];
Expand Down

0 comments on commit 5094579

Please sign in to comment.