ZIP file content type for HTTP request [duplicate]

岁酱吖の 提交于 2019-12-03 08:06:13

问题


I am sending a zip file to server via HTTPREQUEST. What should be the Content-Type HTTP header value for this kind of file?

The file is a ZIP archive that contains images on type PNG.

Thanks


回答1:


.zip    application/zip, application/octet-stream



回答2:


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.

As always, it ultimately depends on your server setup.




回答3:


[request setValue:@"application/zip" forHTTPHeaderField:@"Content-Type"];



回答4:


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.



来源:https://stackoverflow.com/questions/20100445/zip-file-content-type-for-http-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!