Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit 016a480

Browse files
broncowkh237
authored andcommitted
Using custom content type for text field in iOS (#340)
1 parent 57a28e1 commit 016a480

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ios/RNFetchBlobReqBuilder.m

+4-2
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,18 @@ void __block (^getFieldData)(id field) = ^(id field)
201201
RCTLogWarn(@"RNFetchBlob multipart request builder has found a field without `data` or `name` property, the field will be removed implicitly.");
202202
return;
203203
}
204-
contentType = contentType == nil ? @"application/octet-stream" : contentType;
204+
205205
// field is a text field
206206
if([field valueForKey:@"filename"] == nil || content == nil) {
207+
contentType = contentType == nil ? @"text/plain" : contentType;
207208
[formData appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
208209
[formData appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n", name] dataUsingEncoding:NSUTF8StringEncoding]];
209-
[formData appendData:[[NSString stringWithFormat:@"Content-Type: text/plain\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
210+
[formData appendData:[[NSString stringWithFormat:@"Content-Type: %@\r\n\r\n", contentType] dataUsingEncoding:NSUTF8StringEncoding]];
210211
[formData appendData:[[NSString stringWithFormat:@"%@\r\n", content] dataUsingEncoding:NSUTF8StringEncoding]];
211212
}
212213
// field contains a file
213214
else {
215+
contentType = contentType == nil ? @"application/octet-stream" : contentType;
214216
NSMutableData * blobData;
215217
if(content != nil)
216218
{

0 commit comments

Comments
 (0)