Skip to content

Commit 8664b57

Browse files
committed
use a temporary file for the resized image
1 parent 7ba9b0d commit 8664b57

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

android/src/main/java/com/imagepicker/ImagePickerModule.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -377,18 +377,8 @@ private File getResizedImage (final String realPath, final int initialWidth, fin
377377
scaledphoto = Bitmap.createScaledBitmap(photo, newWidth, newHeight, true);
378378
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
379379
scaledphoto.compress(Bitmap.CompressFormat.JPEG, quality, bytes);
380-
String filname = UUID.randomUUID().toString();
381-
File path = Environment.getExternalStoragePublicDirectory(
382-
Environment.DIRECTORY_PICTURES);
383-
File f = new File(path, filname +".jpg");
384-
try {
385-
// Make sure the Pictures directory exists.
386-
path.mkdirs();
387-
388-
f.createNewFile();
389-
} catch (IOException e) {
390-
e.printStackTrace();
391-
}
380+
String filname = "resized-" + UUID.randomUUID().toString() + ".jpg";
381+
File f = new File(mReactContext.getCacheDir(), filname);
392382
FileOutputStream fo;
393383
try {
394384
fo = new FileOutputStream(f);

0 commit comments

Comments
 (0)