Open ebeliejinfren opened 3 years ago
@nadav2051 Not working, I used this patch-package diff:
diff --git a/node_modules/rn-fetch-blob/polyfill/Fetch.js b/node_modules/rn-fetch-blob/polyfill/Fetch.js
index 3ecb591..979f714 100644
--- a/node_modules/rn-fetch-blob/polyfill/Fetch.js
+++ b/node_modules/rn-fetch-blob/polyfill/Fetch.js
@@ -40,6 +40,7 @@ class RNFetchBlobFetchPolyfill {
promise = Blob.build(body).then((b) => {
blobCache = b
options.headers['Content-Type'] = 'multipart/form-data;boundary=' + b.multipartBoundary
+ options.headers['content-type'] = 'multipart/form-data;boundary=' + b.multipartBoundary
return Promise.resolve(RNFetchBlob.wrap(b._ref))
})
}
@@ -58,10 +59,14 @@ class RNFetchBlobFetchPolyfill {
// task.then is not, so we have to extend task.then with progress and
// cancel function
let progressHandler, uploadHandler, cancelHandler
+
+ let scopedTask = null
+
let statefulPromise = promise
.then((body) => {
let task = RNFetchBlob.config(config)
- .fetch(options.method, url, options.headers, body)
+ .fetch(options.method, url, options.headers, body)
+ scopedTask = task
if(progressHandler)
task.progress(progressHandler)
if(uploadHandler)
@@ -86,12 +91,11 @@ class RNFetchBlobFetchPolyfill {
}
statefulPromise.cancel = () => {
cancelHandler = true
- if(task.cancel)
- task.cancel()
+ if(scopedTask && scopedTask.cancel)
+ scopedTask.cancel()
}
return statefulPromise
-
}
}
i use rn-fetch-blob to download file in React Native every thing work correct but when use cancel method according to doc, cancelling not work and got error "fileFetchPromise Is Not Defained"