Skip to content

Commit 9ac9c6f

Browse files
authored
Merge pull request wkh237#118 from ihavenoface5/TaskProgress
Fixed truncating of progress report values.
2 parents ebc320f + 5094579 commit 9ac9c6f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

android/src/main/java/com/RNFetchBlob/RNFetchBlobBody.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ private File createMultipartBodyCache() throws IOException {
281281
*/
282282
private void pipeStreamToSink(InputStream stream, BufferedSink sink) throws IOException {
283283
byte[] chunk = new byte[10240];
284-
int totalWritten = 0;
284+
long totalWritten = 0;
285285
int read;
286286
while((read = stream.read(chunk, 0, 10240)) > 0) {
287287
sink.write(chunk, 0, read);
@@ -403,7 +403,7 @@ private class FormField {
403403
* Emit progress event
404404
* @param written Integer
405405
*/
406-
private void emitUploadProgress(int written) {
406+
private void emitUploadProgress(long written) {
407407
RNFetchBlobProgressConfig config = RNFetchBlobReq.getReportUploadProgress(mTaskId);
408408
if(config != null && contentLength != 0 && config.shouldReport((float)written/contentLength)) {
409409
WritableMap args = Arguments.createMap();

ios/RNFetchBlobRequest.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ - (void) URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dat
345345
sendDeviceEventWithName:EVENT_PROGRESS
346346
body:@{
347347
@"taskId": taskId,
348-
@"written": [NSString stringWithFormat:@"%ld", (long) receivedBytes],
349-
@"total": [NSString stringWithFormat:@"%ld", (long) expectedBytes],
348+
@"written": [NSString stringWithFormat:@"%lld", (long long) receivedBytes],
349+
@"total": [NSString stringWithFormat:@"%lld", (long long) expectedBytes],
350350
@"chunk": chunkString
351351
}
352352
];

0 commit comments

Comments
 (0)