Skip to content

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

Open
@raedhellal

Description

@raedhellal

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions