Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
cf442e53d2
|
@ -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) {
|
||||||
|
if (UTTypeConformsTo((__bridge CFStringRef)dataUTI, kUTTypeJPEG)) {
|
||||||
firmetadata.contentType = [self utiToMimeType:dataUTI];
|
firmetadata.contentType = [self utiToMimeType:dataUTI];
|
||||||
[self uploadData:appName data:imageData firmetadata:firmetadata path:path resolver:resolve rejecter:reject];
|
[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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue