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
101 stars 16 forks source link

[REQUEST] Add ability to save media files from bytes (Uint8List) #20

Closed kamranbekirovyz closed 1 year ago

kamranbekirovyz commented 1 year ago

Problem this request is trying to solve Hi. Today I started looking at packages for saving media files to the device gallery app and found this package very clean, maintained, and useful for this purpose.

However, in order to save a media file that is on Memory (as bytes), I should do this: write to a temporary directory, then export to the gallery app.

Screenshot 2023-07-03 at 19 11 47

Would you consider if I open a PR for this built-in feature which will require path_provider package as a dependency?

natsuk4ze commented 1 year ago

@kamranbekirovyz Thank you for your contribution🤟. Please wait as I investigate.

natsuk4ze commented 1 year ago

@kamranbekirovyz Can you provide more details? What kind of use cases do you envision, like storing images taken with a camera?

kamranbekirovyz commented 1 year ago

There are low details on the issue because I was in a hurry 🙂

For example, screenshot package when takes a screenshot, the resulting image is not a Filewith path but byte data (Uint8List), so, you can not export it with gal: you need to save it with locally before. Is it more clear?

natsuk4ze commented 1 year ago

@kamranbekirovyz Thank you very much. I understand. If there is a lot of demand for it, maybe it should be included in the gal. However, if it can be solved with a few lines of code, it might be best to not include that functionality to keep the package minimalistic and provide documentation instead.

By the way, as you can see in the example, getting temporary folders can be accomplished with Directory.systemTemp without using path_provider.

kamranbekirovyz commented 1 year ago

Let me know if you need help in implementing this feature in future.

BTW, I'm working on an article that will promote gal as a preferred option for saving media files to the gallery app. I'll send you the article link when ready.

natsuk4ze commented 1 year ago

@kamranbekirovyz Wow! That is great news. I appreciate it.

This is not finalized yet, but I may release a major update as a pre-release version. The changes are as follows

This will be released as a pre-release version, especially since the removal of the permission handle function is controversial.

kamranbekirovyz commented 1 year ago

Good Luck & keep in touch.

natsuk4ze commented 1 year ago

@kamranbekirovyz After a bit of thought, I decided to work on implementing the ability to save media in a Uint8List. Instead of using a temporary folder, I will pass Uint8List directly to the native code to save it. It is probably possible.

natsuk4ze commented 1 year ago

Released🔥 Thank you for your request @kamranbekirovyz .