Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get MIME type of an ALAsset

Is there a way how to get MIME type for ALAsset? There is a nice method for metadata:

NSDictionary *data = [[asset defaultRepresentation] metadata];

But that doesn't contain MIME type data...

like image 315
Michal Avatar asked Dec 06 '22 02:12

Michal


1 Answers

ALAssetRepresentation *rep = [asset defaultRepresentation];

NSString* MIMEType = (__bridge_transfer NSString*)UTTypeCopyPreferredTagWithClass
             ((__bridge CFStringRef)[rep UTI], kUTTagClassMIMEType);

This will give you the MIME type. You need to add MobileCoreService framework and import <MobileCoreServices/MobileCoreServices.h>

like image 133
Boran Avatar answered Dec 24 '22 12:12

Boran