Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit e70e5f5

Browse files
author
Miguel Ruivo
committed
adds error handler when caching a video file from the picker
1 parent c4b1f9e commit e70e5f5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/image_picker/ios/Classes/ImagePickerPlugin.m

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,21 @@ - (void)imagePickerController:(UIImagePickerController *)picker
247247
[NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:fileName]];
248248

249249
if ([[NSFileManager defaultManager] isReadableFileAtPath:[videoURL path]]) {
250-
[[NSFileManager defaultManager] copyItemAtURL:videoURL toURL:destination error:nil];
250+
NSError *error;
251+
[[NSFileManager defaultManager] copyItemAtURL:videoURL toURL:destination error:&error];
252+
if (error) {
253+
self.result([FlutterError errorWithCode:@"flutter_image_picker_copy_video_error"
254+
message:@"Could not cache the video file."
255+
details:nil]);
256+
self.result = nil;
257+
return;
258+
}
251259
videoURL = destination;
252260
}
253261
}
254262
self.result(videoURL.path);
255263
self.result = nil;
264+
256265
} else {
257266
UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
258267
if (image == nil) {

0 commit comments

Comments
 (0)