Skip to content

Commit 5971ce8

Browse files
committed
Implement initial uploadProgress tracking
1 parent a3b3dbe commit 5971ce8

File tree

3 files changed

+270
-285
lines changed

3 files changed

+270
-285
lines changed

RNFetchBlobWin/App.js

+10-13
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,11 @@ const App: () => React$Node = () => {
442442
// (you can use "base64"(refer to the library 'mathiasbynens/base64') APIs to make one).
443443
// The data will be converted to "byte array"(say, blob) before request sent.
444444
}, "Waka Flacka Flame goes very well with Thomas the Tank Engine.")
445+
.uploadProgress((received, total) => {
446+
console.log('upload progress', received / total)
447+
})
445448
.progress((received, total) => {
446-
console.log('progress', received / total)
449+
console.log('download progress', received / total)
447450
})
448451
.then((res) => {
449452
console.log(res.text());
@@ -458,8 +461,6 @@ const App: () => React$Node = () => {
458461
RNFetchBlob.config({
459462
// add this option that makes response data to be stored as a file,
460463
// this is much more performant.
461-
Progress: {count : 10, interval : 10},
462-
UploadProgress: {count : 10, interval : 10},
463464
fileCache : true,
464465
}).fetch('POST', 'https://enb954aqyumba.x.pipedream.net/', {
465466
Authorization : "Bearer access-token",
@@ -478,12 +479,14 @@ const App: () => React$Node = () => {
478479
mail : 'example@example.com',
479480
tel : '12345678'
480481
})},
481-
]).progress((received, total) => {
482-
console.log('progress', received / total)
482+
]).uploadProgress({ interval : 250 }, (written, total) => {
483+
console.log('uploaded', written / total)
484+
}).progress({ count : 10, interval: -1 }, (received, total) => {
485+
console.log('progress', received / total)
483486
}).then((res) => {
484-
console.log(res.text());
487+
console.log(res.text());
485488
}).catch((err) => {
486-
// error handling ..
489+
console.log(err.text());
487490
})
488491
}
489492

@@ -890,12 +893,6 @@ const App: () => React$Node = () => {
890893
{"FetchBlobTest"}
891894
</Text>
892895
<View style={styles.sectionDescription}>
893-
<TextInput style = {styles.input}
894-
placeholder = "Source path"
895-
onChangeText={readStreamParam => setReadStreamParam(readStreamParam)}
896-
placeholderTextColor = "#9a73ef"
897-
autoCapitalize = "none"
898-
/>
899896
</View>
900897
<Button
901898
title="Attempt Fetch"

0 commit comments

Comments
 (0)