Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IOS] File content type is always "application/octet-stream" #316

Open
raedhellal opened this issue Nov 7, 2022 · 1 comment
Open

[IOS] File content type is always "application/octet-stream" #316

raedhellal opened this issue Nov 7, 2022 · 1 comment

Comments

@raedhellal
Copy link

I had a problem with uploading document and the issue is that the content type is always "application/octet-stream" when i checked the code i found this function:

/*
Borrowed from http://stackoverflow.com/questions/2439020/wheres-the-iphone-mime-type-database
*/

  • (NSString *)guessMIMETypeFromFileName: (NSString *)fileName {
    CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)[fileName pathExtension], NULL);
    CFStringRef MIMEType = UTTypeCopyPreferredTagWithClass(UTI, kUTTagClassMIMEType);

    if (UTI) {
    CFRelease(UTI);
    }

    if (!MIMEType) {
    return @"application/octet-stream";
    }
    return (__bridge NSString *)(MIMEType);
    }

i guess this two lines don't work anymore to determine MIMEType
CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)[fileName pathExtension], NULL);
CFStringRef MIMEType = UTTypeCopyPreferredTagWithClass(UTI, kUTTagClassMIMEType);

it is always null

@bityogi
Copy link

bityogi commented Apr 21, 2023

Hello,

Is there a way around this? We are trying to upload HEIF images from iOS devices (with an file extension of heic) and the contentType seems to be coming back as application/octet-stream and this is causing some issues for us because we need to redirect them for processing based on the contentType if they are heif images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants