I've used image_picker to grab images and videos from the phone's gallery, but as far as I can tell, persisting those media for later use requires saving them to another directory, i.e. the app's storage directory, and saving the path to that media in some datastore (which is also what I've done). It looks like even the XFile returned from image_picker has a path to a temp directory.
That being said, is there actually a way to store a reference to media "directly" from the gallery? I'm assuming the difficulty here would lie in the fact that not everything a phone presents on its camera roll is local...which would mean that this using this reference at a later date would require some logic along the lines of, "If local, use the local file, otherwise pull from the cloud" - just like when you share a video captured weeks ago, for example.
My use case here is an Instagram-like app that involves potentially hundreds or thousands of entries, each of which may be linked to a video and / or image file. My current solution is as stated above - allow the user to select a video, and then copy that entire video to the app-specific directory, saving that new path to an object which is then persisted to a local DB.
Obviously that's not very space-efficient and defeats the purpose of the space-saving capabilities of something like iCloud, at least as far as selected media are concerned. But at this time - or maybe ever - I'd rather not implement cloud-based video storage and incur the associated costs and headaches. It'd be great to just store some kind of identifier for the gallery entry itself, so that as long as the user doesn't delete the media from their camera roll, it'll always be available by my app.
I know gallery_saver allows persistence TO the gallery, but that doesn't help when it comes to referencing the media for later user. In fact it doesn't appear that that libraries' methods return anything - they just await the save to the gallery.
Aside from the state current solution, I've tried persisting the temporary file returned from image_picker which predictably did not work. I have yet to see any image_picker method or other library which offers a return that directly references the selected media from the camera roll.