"Content-disposition" should be "form-data" for a single file.

The "Content-disposition" should only be "file" if one of multiple files in a subpart. See the end of http://www.w3.org/TR/html4/interact/forms.html, section 17.13.4, for details. AFNetworking does not currently support creation of subparts where "file" should be used.

This fixes Tornado from failing to parse our file upload.
This commit is contained in:
Michael Parker 2012-01-06 21:24:45 -08:00
parent 430d7618e1
commit 2183dbbbcc

View file

@ -451,7 +451,7 @@ static inline NSString * AFMultipartFormFinalBoundary() {
- (void)appendPartWithFileData:(NSData *)data name:(NSString *)name fileName:(NSString *)fileName mimeType:(NSString *)mimeType {
NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary];
[mutableHeaders setValue:[NSString stringWithFormat:@"file; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"];
[mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"];
[mutableHeaders setValue:mimeType forKey:@"Content-Type"];
[self appendPartWithHeaders:mutableHeaders body:data];