Prefer to deduce the MIME type from the file extension using lookup, not the UTI type.

// FREEBIE
pull/1/head
Matthew Chen 9 years ago
parent cb6de93a83
commit 3e9fbb1bec

@ -2568,11 +2568,16 @@ NSString *const OWSMimeTypeUnknownForTests = @"unknown/mimetype";
+ (nullable NSString *)fileExtensionForMIMEType:(NSString *)mimeType + (nullable NSString *)fileExtensionForMIMEType:(NSString *)mimeType
{ {
// Try to deduce the file extension by converting to a UTI type. // Try to deduce the file extension by using a lookup table.
NSString *_Nullable fileExtension = [self fileExtensionForMIMETypeViaUTIType:mimeType]; //
// This should be more accurate than deducing the file extension by
// converting to a UTI type. For example, .m4a files will have a
// UTI type of kUTTypeMPEG4Audio which incorrectly yields the file
// extension .mp4 instead of .m4a.
NSString *_Nullable fileExtension = [self fileExtensionForMIMETypeViaLookup:mimeType];
if (!fileExtension) { if (!fileExtension) {
// Try to deduce the file extension by using a lookup table.. // Try to deduce the file extension by converting to a UTI type.
fileExtension = [self fileExtensionForMIMETypeViaLookup:mimeType]; fileExtension = [self fileExtensionForMIMETypeViaUTIType:mimeType];
} }
return fileExtension; return fileExtension;
} }

Loading…
Cancel
Save