Browse Source

Merge pull request #118 from ihavenoface5/TaskProgress

Fixed truncating of progress report values.
Travis Nuttall 5 years ago
parent
commit
9ac9c6f251
No account linked to committer's email address

+ 2
- 2
android/src/main/java/com/RNFetchBlob/RNFetchBlobBody.java View File

281
      */
281
      */
282
     private void pipeStreamToSink(InputStream stream, BufferedSink sink) throws IOException {
282
     private void pipeStreamToSink(InputStream stream, BufferedSink sink) throws IOException {
283
         byte[] chunk = new byte[10240];
283
         byte[] chunk = new byte[10240];
284
-        int totalWritten = 0;
284
+        long totalWritten = 0;
285
         int read;
285
         int read;
286
         while((read = stream.read(chunk, 0, 10240)) > 0) {
286
         while((read = stream.read(chunk, 0, 10240)) > 0) {
287
             sink.write(chunk, 0, read);
287
             sink.write(chunk, 0, read);
403
      * Emit progress event
403
      * Emit progress event
404
      * @param written  Integer
404
      * @param written  Integer
405
      */
405
      */
406
-    private void emitUploadProgress(int written) {
406
+    private void emitUploadProgress(long written) {
407
         RNFetchBlobProgressConfig config = RNFetchBlobReq.getReportUploadProgress(mTaskId);
407
         RNFetchBlobProgressConfig config = RNFetchBlobReq.getReportUploadProgress(mTaskId);
408
         if(config != null && contentLength != 0 && config.shouldReport((float)written/contentLength)) {
408
         if(config != null && contentLength != 0 && config.shouldReport((float)written/contentLength)) {
409
             WritableMap args = Arguments.createMap();
409
             WritableMap args = Arguments.createMap();

+ 2
- 2
ios/RNFetchBlobRequest.m View File

345
          sendDeviceEventWithName:EVENT_PROGRESS
345
          sendDeviceEventWithName:EVENT_PROGRESS
346
          body:@{
346
          body:@{
347
                 @"taskId": taskId,
347
                 @"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],
350
                 @"chunk": chunkString
350
                 @"chunk": chunkString
351
                 }
351
                 }
352
          ];
352
          ];