Skip to content

Commit

Permalink
[media-library] Fix getAssetInfoAsync does not return localUri
Browse files Browse the repository at this point in the history
  • Loading branch information
lukmccall committed Sep 30, 2019
1 parent 109756f commit 4a6bd66
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions packages/expo-media-library/ios/EXMediaLibrary/EXMediaLibrary.m
Expand Up @@ -388,19 +388,31 @@ - (NSDictionary *)constantsToExport

if (asset) {
NSMutableDictionary *result = [EXMediaLibrary _exportAssetInfo:asset];
PHContentEditingInputRequestOptions *options = [PHContentEditingInputRequestOptions new];
options.networkAccessAllowed = YES;

[asset requestContentEditingInputWithOptions:options completionHandler:^(PHContentEditingInput * _Nullable contentEditingInput, NSDictionary * _Nonnull info) {
result[@"localUri"] = [contentEditingInput.fullSizeImageURL absoluteString];
result[@"orientation"] = @(contentEditingInput.fullSizeImageOrientation);

if (asset.mediaType == PHAssetMediaTypeImage) {
if (asset.mediaType == PHAssetMediaTypeImage) {
PHContentEditingInputRequestOptions *options = [PHContentEditingInputRequestOptions new];
options.networkAccessAllowed = YES;

[asset requestContentEditingInputWithOptions:options
completionHandler:^(PHContentEditingInput * _Nullable contentEditingInput, NSDictionary * _Nonnull info) {
result[@"localUri"] = [contentEditingInput.fullSizeImageURL absoluteString];
result[@"orientation"] = @(contentEditingInput.fullSizeImageOrientation);

CIImage *ciImage = [CIImage imageWithContentsOfURL:contentEditingInput.fullSizeImageURL];
result[@"exif"] = ciImage.properties;
}
resolve(result);
}];
resolve(result);
}];
} else {
PHVideoRequestOptions *options = [PHVideoRequestOptions new];
options.networkAccessAllowed = YES;

[[PHImageManager defaultManager] requestAVAssetForVideo:asset
options:options
resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
AVURLAsset *urlAsset = (AVURLAsset *)asset;
result[@"localUri"] = [[urlAsset URL] absoluteString];
resolve(result);
}];
}
} else {
resolve([NSNull null]);
}
Expand Down

0 comments on commit 4a6bd66

Please sign in to comment.