diff --git a/README.md b/README.md
index 8831db5cf..5f73c6d81 100644
--- a/README.md
+++ b/README.md
@@ -236,7 +236,7 @@ RNFetchBlob
console.log('The file saved to ', res.path())
// Beware that when using a file path as Image source on Android,
// you must prepend "file://"" before the file path
- imageView =
+ imageView =
})
```
diff --git a/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java b/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java
index aaa837cee..be30a9e66 100644
--- a/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java
+++ b/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java
@@ -255,7 +255,7 @@ else if (value.equalsIgnoreCase("utf8"))
}
}
- if(method.equalsIgnoreCase("post") || method.equalsIgnoreCase("put") || method.equalsIgnoreCase("patch")) {
+ if(method.equalsIgnoreCase("post") || method.equalsIgnoreCase("put") || method.equalsIgnoreCase("patch") || method.equalsIgnoreCase("delete")) {
String cType = getHeaderIgnoreCases(mheaders, "Content-Type").toLowerCase();
if(rawRequestBodyArray != null) {
@@ -316,7 +316,7 @@ else if(cType.isEmpty()) {
break;
case WithoutBody:
- if(method.equalsIgnoreCase("post") || method.equalsIgnoreCase("put") || method.equalsIgnoreCase("patch"))
+ if(method.equalsIgnoreCase("post") || method.equalsIgnoreCase("put") || method.equalsIgnoreCase("patch") || method.equalsIgnoreCase("delete"))
{
builder.method(method, RequestBody.create(null, new byte[0]));
}
diff --git a/index.js b/index.js
index bd67986fa..f66dbff04 100644
--- a/index.js
+++ b/index.js
@@ -229,7 +229,13 @@ function fetch(...args:any):Promise {
}
// from remote HTTP(S)
+ let promiseResolve;
+ let promiseReject;
+
let promise = new Promise((resolve, reject) => {
+ promiseResolve = resolve;
+ promiseReject = reject;
+
let nativeMethodName = Array.isArray(body) ? 'fetchBlobForm' : 'fetchBlob'
// on progress event listener
@@ -370,6 +376,7 @@ function fetch(...args:any):Promise {
subscriptionUpload.remove()
stateEvent.remove()
RNFetchBlob.cancelRequest(taskId, fn)
+ promiseReject(new Error("canceled"))
}
promise.taskId = taskId
diff --git a/ios/RNFetchBlobReqBuilder.m b/ios/RNFetchBlobReqBuilder.m
index b6048f553..f5d2e103d 100644
--- a/ios/RNFetchBlobReqBuilder.m
+++ b/ios/RNFetchBlobReqBuilder.m
@@ -99,8 +99,8 @@ +(void) buildOctetRequest:(NSDictionary *)options
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSMutableData * blobData;
long size = -1;
- // if method is POST, PUT or PATCH, convert data string format
- if([[method lowercaseString] isEqualToString:@"post"] || [[method lowercaseString] isEqualToString:@"put"] || [[method lowercaseString] isEqualToString:@"patch"]) {
+ // if method is POST, PUT, PATCH or DELETE, convert data string format
+ if([[method lowercaseString] isEqualToString:@"post"] || [[method lowercaseString] isEqualToString:@"put"] || [[method lowercaseString] isEqualToString:@"patch"] || [[method lowercaseString] isEqualToString:@"delete"]) {
// generate octet-stream body
if(body != nil) {
__block NSString * cType = [[self class] getHeaderIgnoreCases:@"content-type" fromHeaders:mheaders];
@@ -117,7 +117,6 @@ +(void) buildOctetRequest:(NSDictionary *)options
orgPath = [RNFetchBlobFS getPathOfAsset:orgPath];
if([orgPath hasPrefix:AL_PREFIX])
{
-
[RNFetchBlobFS readFile:orgPath encoding:nil onComplete:^(id content, NSString* code, NSString * err) {
if(err != nil)
{
@@ -131,7 +130,7 @@ +(void) buildOctetRequest:(NSDictionary *)options
onComplete(request, [((NSData *)content) length]);
}
}];
-
+
return;
}
size = [[[NSFileManager defaultManager] attributesOfItemAtPath:orgPath error:nil] fileSize];