Skip to content

Commit bfa38fe

Browse files
authored
fix(ios): return copy of video when picking from gallery on iOS 13 (apache#580)
1 parent 7611960 commit bfa38fe

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/ios/CDVCamera.m

+13
Original file line numberDiff line numberDiff line change
@@ -513,9 +513,22 @@ - (void)resultForImage:(CDVPictureOptions*)options info:(NSDictionary*)info comp
513513
- (CDVPluginResult*)resultForVideo:(NSDictionary*)info
514514
{
515515
NSString* moviePath = [[info objectForKey:UIImagePickerControllerMediaURL] absoluteString];
516+
// On iOS 13 the movie path becomes inaccessible, create and return a copy
517+
if (IsAtLeastiOSVersion(@"13.0")) {
518+
moviePath = [self createTmpVideo:[[info objectForKey:UIImagePickerControllerMediaURL] path]];
519+
}
516520
return [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:moviePath];
517521
}
518522

523+
- (NSString *) createTmpVideo:(NSString *) moviePath {
524+
NSString* moviePathExtension = [moviePath pathExtension];
525+
NSString* copyMoviePath = [self tempFilePath:moviePathExtension];
526+
NSFileManager* fileMgr = [[NSFileManager alloc] init];
527+
NSError *error;
528+
[fileMgr copyItemAtPath:moviePath toPath:copyMoviePath error:&error];
529+
return [[NSURL fileURLWithPath:copyMoviePath] absoluteString];
530+
}
531+
519532
- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
520533
{
521534
__weak CDVCameraPicker* cameraPicker = (CDVCameraPicker*)picker;

0 commit comments

Comments
 (0)