瀏覽代碼

Merge pull request #118 from ihavenoface5/TaskProgress

Fixed truncating of progress report values.
Travis Nuttall 5 年之前
父節點
當前提交
9ac9c6f251
No account linked to committer's email address
共有 2 個文件被更改,包括 4 次插入4 次删除
  1. 2
    2
      android/src/main/java/com/RNFetchBlob/RNFetchBlobBody.java
  2. 2
    2
      ios/RNFetchBlobRequest.m

+ 2
- 2
android/src/main/java/com/RNFetchBlob/RNFetchBlobBody.java 查看文件

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

+ 2
- 2
ios/RNFetchBlobRequest.m 查看文件

@@ -345,8 +345,8 @@ typedef NS_ENUM(NSUInteger, ResponseFormat) {
345 345
          sendDeviceEventWithName:EVENT_PROGRESS
346 346
          body:@{
347 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 350
                 @"chunk": chunkString
351 351
                 }
352 352
          ];