natsuk4ze / gal

How to Save Image or Video to Photo Gallery in Flutter
https://pub.dev/packages/gal
BSD 3-Clause "New" or "Revised" License
105 stars 16 forks source link

Retrieve saved image path after saving to Gallery #216

Closed iqfareez closed 5 months ago

iqfareez commented 6 months ago

Did you check the documentation and it did not help?

Proposal

Hi. Great project! Currenty putImage and putImageBytes both return void after saving the image to gallery. I would like for the function to return the saved image path. I saw similar issue #203 but had no idea it was marked as completed, apologize if there is already a discussion that I may overlooked.

Use case

I would like my app to have function to open image directly quickly after saving.

natsuk4ze commented 6 months ago

Hi @iqfareez . Thanks for your contributionšŸ¤ First, there are some limitations depending on the platform.

  1. iOS/macOS does not allow us to get the direct file path of a media file, so you have to get the local URL e.g. file:///var/mobile/Media/DCIM/118APPLE/IMG_8371.MOV. In addition, this is not possible with NSPhotoLibraryAddUsageDescription, which would require additional permissions.

  2. file paths and URLs cannot be used permanently as they can be changed by the system or the user.

  3. changes to media files should always be made via the platform's API and should not be changed or deleted directly using the path.

I would like my app to have function to open image directly quickly after saving.

Does this mean opening the Gallery app? If not, the easiest way seems to be to display the images using the path to the temporary directory used to store the files.

final imagePath = '${Directory.systemTemp.path}/image.jpg';
await Dio().download('$url',imagePath);
await Gal.putImage(imagePath);
// Open imagePath //

If you tell me more about your Use Case, I may be able to suggest a better way.

github-actions[bot] commented 5 months ago

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. If you find this problem please file a new issue with the same description, Thanks for your contribution.

mcosti commented 3 months ago

Hi, I do have a usecase. I am building a share to instagram story functionality and on Android it's limited, it requires passing a file from MediaStore instead of the app's cache.

I am using Gal for a different functionality, so it would be great to be able to use the same one here