我发送一个压缩文件到服务器通过 HTTPREQUEST。这种文件的 Content-Type HTTP 头 价值应该是什么?
Content-Type
该文件是一个 ZIP 归档文件,其中包含 PNG 类型的图像。
谢谢
The standard MIME type for ZIP files is application/zip. The types for the files inside the ZIP does not matter for the MIME type.
application/zip
As always, it ultimately depends on your server setup.
[request setValue:@"application/zip" forHTTPHeaderField:@"Content-Type"];
.zip application/zip, application/octet-stream
If you want the MIME type for a file, you can use the following code:
- (NSString *)mimeTypeForPath:(NSString *)path { // get a mime type for an extension using MobileCoreServices.framework CFStringRef extension = (__bridge CFStringRef)[path pathExtension]; CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, extension, NULL); assert(UTI != NULL); NSString *mimetype = CFBridgingRelease(UTTypeCopyPreferredTagWithClass(UTI, kUTTagClassMIMEType)); assert(mimetype != NULL); CFRelease(UTI); return mimetype; }
In the case of a ZIP file, this will return application/zip.