ZIP file content type for HTTP request [duplicate]
Asked Answered
R

4

110

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

Raisaraise answered 20/11, 2013 at 15:48 Comment(0)
O
178
.zip    application/zip, application/octet-stream
Outlawry answered 20/11, 2013 at 15:53 Comment(4)
Is this supposed to be a single value or a choice of several?Blacksnake
This won't guarantee you a zip file at all. According to the WC3 specifications this will be intrepreted as: "I prefer a application/zip content type, but if you cannot deliver this an application/octet-stream (file stream) is also fine".Gravamen
Also seen application/x-zip-compressedAraliaceous
application/x-zip-compressed sound like some custom header for specific system. application/zip, application/octet-stream are common.Solo
R
59

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.

Repugn answered 20/11, 2013 at 15:51 Comment(0)
H
4
[request setValue:@"application/zip" forHTTPHeaderField:@"Content-Type"];
Hampden answered 20/11, 2013 at 15:51 Comment(0)
A
2

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.

Ascent answered 20/11, 2013 at 15:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.