Skip to content

Commit

Permalink
Merge pull request #118 from ihavenoface5/TaskProgress
Browse files Browse the repository at this point in the history
Fixed truncating of progress report values.
  • Loading branch information
Traviskn authored Jul 17, 2018
2 parents ebc320f + 5094579 commit 9ac9c6f
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 9ac9c6f

Please sign in to comment.