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

Commit 4b24153

Browse files
ivk1800Chris Yang
authored and
Chris Yang
committed
[image_picker] delete original file if scaled (#1288)
fixed flutter/flutter#23500
1 parent 9017d6e commit 4b24153

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

packages/image_picker/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.5.0+6
2+
3+
* Delete the original image if it was scaled.
4+
15
## 0.5.0+5
26

37
Remove unnecessary camera permmision.

packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,11 @@ private void handleImageResult(String path) {
429429

430430
String finalImagePath = imageResizer.resizeImageIfNeeded(path, maxWidth, maxHeight);
431431
finishWithSuccess(finalImagePath);
432+
433+
//delete original file if scaled
434+
if (!finalImagePath.equals(path)) {
435+
new File(path).delete();
436+
}
432437
} else {
433438
throw new IllegalStateException("Received image from picker that was not requested");
434439
}

packages/image_picker/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors:
55
- Flutter Team <[email protected]>
66
- Rhodes Davis Jr. <[email protected]>
77
homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker
8-
version: 0.5.0+5
8+
version: 0.5.0+6
99

1010
flutter:
1111
plugin:

0 commit comments

Comments
 (0)