Browse Source

Fix FormData compatibility of Blob #44

Ben Hsieh 8 years ago
parent
commit
4affc4dc80

+ 1
- 1
src/android/src/main/java/com/RNFetchBlob/RNFetchBlob.java View File

162
 
162
 
163
     @ReactMethod
163
     @ReactMethod
164
     public void slice(String src, String dest, int start, int end, String encode, Callback callback) {
164
     public void slice(String src, String dest, int start, int end, String encode, Callback callback) {
165
-
165
+        RNFetchBlobFS.slice(src, dest, start, end, encode, callback);
166
     }
166
     }
167
 
167
 
168
     @ReactMethod
168
     @ReactMethod

+ 2
- 2
src/ios/RNFetchBlobReqBuilder.m View File

88
         if([[method lowercaseString] isEqualToString:@"post"] || [[method lowercaseString] isEqualToString:@"put"]) {
88
         if([[method lowercaseString] isEqualToString:@"post"] || [[method lowercaseString] isEqualToString:@"put"]) {
89
             // generate octet-stream body
89
             // generate octet-stream body
90
             if(body != nil) {
90
             if(body != nil) {
91
-                
91
+                NSString * cType = [[self class] getHeaderIgnoreCases:@"content-type" fromHeaders:mheaders];
92
                 // when headers does not contain a key named "content-type" (case ignored), use default content type
92
                 // when headers does not contain a key named "content-type" (case ignored), use default content type
93
-                if([[self class] getHeaderIgnoreCases:@"content-type" fromHeaders:mheaders] == nil)
93
+                if(cType == nil)
94
                 {
94
                 {
95
                     [mheaders setValue:@"application/octet-stream" forKey:@"Content-Type"];
95
                     [mheaders setValue:@"application/octet-stream" forKey:@"Content-Type"];
96
                 }
96
                 }

+ 1
- 1
src/polyfill/File.js View File

10
   name : string = '';
10
   name : string = '';
11
 
11
 
12
   static build(name:string, data:any, cType):Promise<File> {
12
   static build(name:string, data:any, cType):Promise<File> {
13
-    this.name = name
14
     return new Promise((resolve, reject) => {
13
     return new Promise((resolve, reject) => {
15
       new File(data, cType).onCreated((f) => {
14
       new File(data, cType).onCreated((f) => {
15
+        f.name = name
16
         resolve(f)
16
         resolve(f)
17
       })
17
       })
18
     })
18
     })