From 8737bbd0c5753d35bca8d6b46a1414aeadff02b3 Mon Sep 17 00:00:00 2001 From: Yedidya Kennard Date: Tue, 3 May 2016 08:51:58 -0700 Subject: [PATCH] Corrected bug that put the UTI instead of mimeType in retrieved assets Summary: This pull request corrects a bug found in `RCTAssetsLibraryRequestHandler` which used the asset UTI as the mimeType. The code for finding the mimeType is based on the implementation used in `RCTImageLoader` and `RCTImageUtils`. Closes https://github.com/facebook/react-native/pull/7349 Differential Revision: D3252796 Pulled By: nicklockwood fb-gh-sync-id: b9303a99333e4744dfe23045f4a2755307305772 fbshipit-source-id: b9303a99333e4744dfe23045f4a2755307305772 --- RCTAssetsLibraryRequestHandler.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/RCTAssetsLibraryRequestHandler.m b/RCTAssetsLibraryRequestHandler.m index d818f336d..a7a44bbb4 100644 --- a/RCTAssetsLibraryRequestHandler.m +++ b/RCTAssetsLibraryRequestHandler.m @@ -11,6 +11,7 @@ #import #import +#import #import "RCTBridge.h" #import "RCTUtils.h" @@ -53,10 +54,13 @@ RCT_EXPORT_MODULE() ALAssetRepresentation *representation = [asset defaultRepresentation]; NSInteger length = (NSInteger)representation.size; + + + CFStringRef MIMEType = UTTypeCopyPreferredTagWithClass((__bridge CFStringRef _Nonnull)(representation.UTI), kUTTagClassMIMEType); NSURLResponse *response = [[NSURLResponse alloc] initWithURL:request.URL - MIMEType:representation.UTI + MIMEType:(__bridge NSString *)(MIMEType) expectedContentLength:length textEncodingName:nil];