Skip to content

[image_picker] image file in gallery is deleted by image_picker if it was scaled #29664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
microdog opened this issue Mar 20, 2019 · 6 comments
Closed

Comments

@microdog
Copy link

microdog commented Mar 20, 2019

When picking an image from the gallery using the image_picker plugin, the image file in the gallery is deleted by image_picker if the image is scaled(exceeds the maxWidth or maxHeight limit).

It seems that this issue was introduced in flutter/plugins#1288 which was intended to delete the original image captured from the camera(#23500), but the patch forgot to check the image source.

Steps to Reproduce

  1. use the image_picker plugin: 0.5.0+9 (issue introduced in 0.5.0+6)
  2. just write a simple demo to pick an image from the gallery with maxWidth and maxHeight set.
  3. pick an image from the gallery which exceeds the maxWidth and maxHeight limit.
  4. Boom. The original image file just vanished.

Logs

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel dev, v1.3.13, on Mac OS X 10.14.3 18D109, locale en-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
[✓] Android Studio (version 3.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2018.3.5)
[✓] VS Code (version 1.32.3)
[!] Proxy Configuration
    ! NO_PROXY is not set
[✓] Connected device (1 available)

! Doctor found issues in 1 category.
@microdog
Copy link
Author

microdog commented Mar 20, 2019

Not all devices are affected by this issue. If the resolved file path is scoped in the Android app package, it is ok to delete the file. But the resolved file path on many of our test devices points to the original image file, for example, in /storage/emulated/0/DCIM/Camera. It seems that some devices refuse to delete the file.

Some of our devices affected:

  • OnePlus 6(A6000) - Android 9(OP6_H2_BETA_17, A6000_22_190309)
  • Xiaomi MI 8 - Android 9(MIUI 10.2.2.0)

Some of our devices NOT affected:

  • Pixel 2 XL - Android 9(PQ1A.190105.004)
  • Xiaomi MI 5s Plus - Android 8(MIUI 10.2.1.0)

@kamalzakaria
Copy link

kamalzakaria commented Mar 29, 2019

having the same issue here:
Xiaomi redmi 6
Samsung Galaxy S 9

@tlcheah2
Copy link

I forked the plugins and did a temporary fix. You can use my fork temporary

image_picker:
    git:
      url: git://github.com/tlcheah2/plugins.git
      path: packages/image_picker

@microdog
Copy link
Author

microdog commented Mar 29, 2019

Any update on this? The PR was created a week ago but no feedback was received.

Some other image_picker issues caused by "file not found" error may also be caused by this issue because the user can select an image from the gallery whose file has already been deleted.

@microdog
Copy link
Author

This should be fixed in flutter/plugins#1445.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants