File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -52,9 +52,13 @@ export let takePicture = function (options?): Promise<any> {
5252 let tempPictureUri ;
5353
5454 if ( saveToGallery ) {
55- picturePath = android . os . Environment . getExternalStoragePublicDirectory (
56- android . os . Environment . DIRECTORY_DCIM ) . getAbsolutePath ( ) + "/Camera/" + "NSIMG_" + dateStamp + ".jpg" ;
57-
55+ // reference the expected public output dir
56+ const dir = android . os . Environment . getExternalStoragePublicDirectory ( android . os . Environment . DIRECTORY_DCIM ) . getAbsolutePath ( ) + "/Camera/" ;
57+ const dirFile = new java . io . File ( dir ) ;
58+ // and create it, if it doesn't exist (Android won't do it on 28+)
59+ if ( ! dirFile . exists ( ) )
60+ dirFile . mkdir ( ) ;
61+ picturePath = dirFile . getAbsolutePath ( ) + "/NSIMG_" + dateStamp + ".jpg" ;
5862 nativeFile = new java . io . File ( picturePath ) ;
5963 } else {
6064 picturePath = utils . ad . getApplicationContext ( ) . getExternalFilesDir ( null ) . getAbsolutePath ( ) + "/" + "NSIMG_" + dateStamp + ".jpg" ;
@@ -111,6 +115,12 @@ export let takePicture = function (options?): Promise<any> {
111115 }
112116 }
113117
118+ // verify that there is a file where we expect one
119+ const picFile = new java . io . File ( picturePath ) ;
120+ if ( ! picFile . exists ( ) ) {
121+ return reject ( 'Cannot locate the picture file' ) ;
122+ }
123+
114124 let exif = new android . media . ExifInterface ( picturePath ) ;
115125 let orientation = exif . getAttributeInt ( android . media . ExifInterface . TAG_ORIENTATION ,
116126 android . media . ExifInterface . ORIENTATION_NORMAL ) ;
You can’t perform that action at this time.
0 commit comments