fix: Revert "Convert PHAsset to JPEG for uploading" (#207)

This reverts commit c958493441.

fixes #193

BREAKING CHANGE: this reverts forcing all mime types to jpeg on upload, which is the cause of lost GIF data
This commit is contained in:
Bartol Karuza 2020-06-24 11:21:42 +03:00 committed by GitHub
parent 9d6aab1aa0
commit a09af08f0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 32 deletions

View File

@ -118,38 +118,6 @@ RCT_EXPORT_MODULE()
}
[delegate URLRequest:cancellationBlock didCompleteWithError:error];
}];
} else if (isPHUpload) {
// By default, allow downloading images from iCloud
PHImageRequestOptions *const requestOptions = [PHImageRequestOptions new];
requestOptions.networkAccessAllowed = YES;
requestOptions.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat;
CGSize const targetSize = CGSizeMake((CGFloat)asset.pixelWidth, (CGFloat)asset.pixelHeight);
[[PHImageManager defaultManager] requestImageForAsset:asset
targetSize:targetSize
contentMode:PHImageContentModeDefault
options:requestOptions
resultHandler:^(UIImage * _Nullable image,
NSDictionary * _Nullable info) {
NSError *const error = [info objectForKey:PHImageErrorKey];
if (error) {
[delegate URLRequest:cancellationBlock didCompleteWithError:error];
return;
}
NSData *const imageData = UIImageJPEGRepresentation(image, 1.0);
NSInteger const length = [imageData length];
NSURLResponse *const response = [[NSURLResponse alloc] initWithURL:request.URL
MIMEType:@"image/jpeg"
expectedContentLength:length
textEncodingName:nil];
[delegate URLRequest:cancellationBlock didReceiveResponse:response];
[delegate URLRequest:cancellationBlock didReceiveData:imageData];
[delegate URLRequest:cancellationBlock didCompleteWithError:nil];
}];
} else {
// By default, allow downloading images from iCloud
PHImageRequestOptions *const requestOptions = [PHImageRequestOptions new];