rodrigograca31 / Canvas2ImagePlugin

PhoneGap / Cordova plugin for iOS to save the contents of an HTML canvas to the device's Photo Library
19 stars 13 forks source link

issue with getting the correct path/filename back #18

Open isaacbdawson opened 3 years ago

isaacbdawson commented 3 years ago

I am having an issue with getting the correct path/filename back.

The plugin is returning: file:///external/images/media/12035

however I find the file itself physically on the device here: /storage/emulated/0/Pictures/c2i_1605857769374.png

the project is using cordova android@9 with a target sdk of 29 the device is running Android 10

any help in resolving this would be greatly appreciated!

edit: it seems this might be (at least partially) related to Android 10 scoped storage? my camera plugin stores images like this: file:///storage/emulated/0/Android/data/com.appname.here/cache/1605859328822.jpg and those work fine.

rodrigograca31 commented 3 years ago

I've seen all those types of paths.... This is the line that returns it:

https://github.com/rodrigograca31/Canvas2ImagePlugin/blob/52ec655ad453043f618a68e339927c9579f3d067/src/android/Canvas2ImagePlugin.java#L118

Also not sure if you ommited some numbers or System.currentTimeMillis() on your phone returns only "160585" 🤔🤔🤔 That could explain some problems I've had on my app.....

rodrigograca31 commented 3 years ago

Feel free to play with the returned value but not sure I will be able to accept a PR as changing that is a big change.

isaacbdawson commented 3 years ago

Apologies, I edited the original comment, it was late and I must have accidentally cut off the file name of the png.

For clarification.

The issue is not just the path it returns (which appears to be wrong), but where it is actually storing it. As from my limited research it appears even if it did somehow return the correct path, under Android 10 it wouldn't be accessible to the app itself due to scoped storage.

I guess there is a scenario where all you might need the plugin for is saving the canvas to an image somewhere on the device, and that is it... but I would think most use cases of such a plugin involve actually addressing the image in some manner.

rodrigograca31 commented 3 years ago

yeah, unfortunately, I don't have enough Android knowledge to be able to fix it in a way that it stores correctly and returns a usable path. :cry:

rodrigograca31 commented 3 years ago

please feel free to send a PR or open a bounty for someone to do it...