Merge remote-tracking branch 'origin/master'

This commit is contained in:
Salakar 2017-09-30 19:21:33 +01:00
commit cf442e53d2
1 changed files with 16 additions and 2 deletions

View File

@ -221,8 +221,22 @@ RCT_EXPORT_METHOD(putFile:(NSString *) appName
options.networkAccessAllowed = true; options.networkAccessAllowed = true;
[[PHImageManager defaultManager] requestImageDataForAsset:asset options:options resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) { [[PHImageManager defaultManager] requestImageDataForAsset:asset options:options resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) {
if (info[PHImageErrorKey] == nil) { if (info[PHImageErrorKey] == nil) {
firmetadata.contentType = [self utiToMimeType:dataUTI]; if (UTTypeConformsTo((__bridge CFStringRef)dataUTI, kUTTypeJPEG)) {
[self uploadData:appName data:imageData firmetadata:firmetadata path:path resolver:resolve rejecter:reject]; firmetadata.contentType = [self utiToMimeType:dataUTI];
[self uploadData:appName data:imageData firmetadata:firmetadata path:path resolver:resolve rejecter:reject];
} else {
// if the image UTI is not JPEG then convert to JPEG, e.g. HEI
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)imageData, NULL);
NSDictionary *imageInfo = (__bridge NSDictionary*)CGImageSourceCopyPropertiesAtIndex(source, 0, NULL);
NSDictionary *imageMetadata = [imageInfo copy];
NSMutableData *imageDataJPEG = [NSMutableData data];
CGImageDestinationRef destination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageDataJPEG, kUTTypeJPEG, 1, NULL);
CGImageDestinationAddImageFromSource(destination, source, 0, (__bridge CFDictionaryRef)imageMetadata);
CGImageDestinationFinalize(destination);
// Manually set mimetype to JPEG
firmetadata.contentType = @"image/jpeg";
[self uploadData:appName data:[NSData dataWithData:imageDataJPEG] firmetadata:firmetadata path:path resolver:resolve rejecter:reject];
}
} else { } else {
reject(@"storage/request-image-data-failed", @"Could not obtain image data for the specified file.", nil); reject(@"storage/request-image-data-failed", @"Could not obtain image data for the specified file.", nil);
} }