Skip to content

Commit

Permalink
Merge pull request #736 from wymsee/ph-uri
Browse files Browse the repository at this point in the history
Added support for ph:// uris to copyAssetsFileIOS
  • Loading branch information
itinance authored Oct 19, 2019
2 parents a77e79a + 026b301 commit fead831
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ android/*.iml
android/local.properties
android/.settings
android/.project
Session.vim
7 changes: 6 additions & 1 deletion RNFSManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,12 @@ + (BOOL)requiresMainQueueSetup
CGSize size = CGSizeMake(width, height);

NSURL* url = [NSURL URLWithString:imageUri];
PHFetchResult *results = [PHAsset fetchAssetsWithALAssetURLs:@[url] options:nil];
PHFetchResult *results = nil;
if ([url.scheme isEqualToString:@"ph"]) {
results = [PHAsset fetchAssetsWithLocalIdentifiers:@[[imageUri substringFromIndex: 5]] options:nil];
} else {
results = [PHAsset fetchAssetsWithALAssetURLs:@[url] options:nil];
}

if (results.count == 0) {
NSString *errorText = [NSString stringWithFormat:@"Failed to fetch PHAsset with local identifier %@ with no error message.", imageUri];
Expand Down

0 comments on commit fead831

Please sign in to comment.