zip file content type for http request [duplicate]

2019-03-14 06:14发布

This question already has an answer here:

I am sending a zip file to server via HTTPREQUEST what should the content-type be for this kind of file? the file is zip file that contains images on type png.

thanks

4条回答
别忘想泡老子
2楼-- · 2019-03-14 06:40

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楼-- · 2019-03-14 06:49
.zip    application/zip, application/octet-stream
查看更多
仙女界的扛把子
4楼-- · 2019-03-14 06:49

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.

查看更多
干净又极端
5楼-- · 2019-03-14 06:50
[request setValue:@"application/zip" forHTTPHeaderField:@"Content-Type"];
查看更多
登录 后发表回答