|
@@ -129,7 +129,7 @@ RCT_EXPORT_METHOD(fetchBlobForm:(NSDictionary *)options
|
129
|
129
|
|
130
|
130
|
// send HTTP request
|
131
|
131
|
RNFetchBlobNetwork * utils = [[RNFetchBlobNetwork alloc] init];
|
132
|
|
- [utils sendRequest:options bridge:self.bridge taskId:taskId withRequest:request withData:postData callback:callback];
|
|
132
|
+ [utils sendRequest:options bridge:self.bridge taskId:taskId withRequest:request callback:callback];
|
133
|
133
|
});
|
134
|
134
|
}
|
135
|
135
|
|
|
@@ -147,7 +147,6 @@ RCT_EXPORT_METHOD(fetchBlob:(NSDictionary *)options
|
147
|
147
|
URLWithString: url]];
|
148
|
148
|
|
149
|
149
|
NSMutableDictionary *mheaders = [[NSMutableDictionary alloc] initWithDictionary:[RNFetchBlobNetwork normalizeHeaders:headers]];
|
150
|
|
-
|
151
|
150
|
// move heavy task to another thread
|
152
|
151
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
153
|
152
|
NSMutableData * blobData;
|
|
@@ -159,12 +158,15 @@ RCT_EXPORT_METHOD(fetchBlob:(NSDictionary *)options
|
159
|
158
|
// when body is a string contains file path prefix, try load file from the path
|
160
|
159
|
if([body hasPrefix:self.filePathPrefix]) {
|
161
|
160
|
NSString * orgPath = [body substringFromIndex:[self.filePathPrefix length]];
|
162
|
|
- blobData = [[NSData alloc] initWithContentsOfFile:orgPath];
|
|
161
|
+ [request setHTTPBodyStream: [NSInputStream inputStreamWithFileAtPath:orgPath ]];
|
|
162
|
+// blobData = [[NSData alloc] initWithContentsOfFile:orgPath];
|
163
|
163
|
}
|
164
|
164
|
// otherwise convert it as BASE64 data string
|
165
|
|
- else
|
|
165
|
+ else {
|
166
|
166
|
blobData = [[NSData alloc] initWithBase64EncodedString:body options:0];
|
167
|
|
- [request setHTTPBody:blobData];
|
|
167
|
+ [request setHTTPBody:blobData];
|
|
168
|
+ }
|
|
169
|
+
|
168
|
170
|
[mheaders setValue:@"application/octet-stream" forKey:@"content-type"];
|
169
|
171
|
|
170
|
172
|
}
|
|
@@ -175,7 +177,7 @@ RCT_EXPORT_METHOD(fetchBlob:(NSDictionary *)options
|
175
|
177
|
|
176
|
178
|
// send HTTP request
|
177
|
179
|
RNFetchBlobNetwork * utils = [[RNFetchBlobNetwork alloc] init];
|
178
|
|
- [utils sendRequest:options bridge:self.bridge taskId:taskId withRequest:request withData:blobData callback:callback];
|
|
180
|
+ [utils sendRequest:options bridge:self.bridge taskId:taskId withRequest:request callback:callback];
|
179
|
181
|
});
|
180
|
182
|
}
|
181
|
183
|
|