Skip to content

Commit

Permalink
fix(ios): return copy of video when picking from gallery on iOS 13 (#580
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jcesarmobile authored Apr 15, 2020
1 parent 7611960 commit bfa38fe
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/ios/CDVCamera.m
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,22 @@ - (void)resultForImage:(CDVPictureOptions*)options info:(NSDictionary*)info comp
- (CDVPluginResult*)resultForVideo:(NSDictionary*)info
{
NSString* moviePath = [[info objectForKey:UIImagePickerControllerMediaURL] absoluteString];
// On iOS 13 the movie path becomes inaccessible, create and return a copy
if (IsAtLeastiOSVersion(@"13.0")) {
moviePath = [self createTmpVideo:[[info objectForKey:UIImagePickerControllerMediaURL] path]];
}
return [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:moviePath];
}

- (NSString *) createTmpVideo:(NSString *) moviePath {
NSString* moviePathExtension = [moviePath pathExtension];
NSString* copyMoviePath = [self tempFilePath:moviePathExtension];
NSFileManager* fileMgr = [[NSFileManager alloc] init];
NSError *error;
[fileMgr copyItemAtPath:moviePath toPath:copyMoviePath error:&error];
return [[NSURL fileURLWithPath:copyMoviePath] absoluteString];
}

- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
{
__weak CDVCameraPicker* cameraPicker = (CDVCameraPicker*)picker;
Expand Down

0 comments on commit bfa38fe

Please sign in to comment.