I have found lots of answers regarding how to download and save online photos to the app's cache or temporary directory. However, I need to know how to copy an image from the device's local gallery to the app's cache.
The reason for this is a strange problem with iOS, where attempting to upload images to Firebase, using paths of images in the gallery, always fails in a physical device and always works in iOS simulator and Android (both physical and simulated). In the app I am building I also have the ability to take photos, which are saved to the app's directories by the camera app, and those uploads work fine. I need to try and first copy the images to my cache, to test if it will allow me to upload them to firebase successfully. I am using multi_image_picker to get the local paths of the selected images from the gallery, all I need is to know, once I have those paths, how to copy a single one of those files to my app's temp directory (I use path_provider to get the appropriate path to temp directory).
It probably isn't a permissions issue because I have both Camera and Photo Library permissions in my plist.info, I get prompted for access and I can access the gallery without a problem when using the multi picker.
I have tried looking at the camera plugin's files and figure out how it does it, but no luck, I get lost once the plugin calls native methods.
I appreciate any help.
Related
I have a Flutter application that uploads pictures with image Picker and keeps track of the file path until the user connects to the internet and synchronize it, however some iOS users found that the images picked by Image Picker are deleted (No such file or Directoty), does this usually happen and the cache might be removed by time?
As documentation of image_picker says:
Images and videos picked using the camera are saved to your application's
local cache, and should therefore be expected to only be around temporarily.
If you require your picked image to be stored permanently,
it is your responsibility to move it to a more permanent location.
I have developed a Flutter app that captures images using the camera and I store references to the image files using Shared Preferences.
When I upgrade the iOS app, the Shared Preference filename persists as expected, but the image no longer displays on the iOS device (and no longer seems to exist) File(_imageFileRef).existsSync() is false
For example, on iPhone, the image file is saved as
/private/var/mobile/Containers/Data/Application/580A9879-23CD-413D-A785-DB910673DF74/tmp/some_guid_image_name.jpg
When the app is upgraded, this file no longer seems to exist.
Where should I be saving the image files to in iOS so that they persist across upgrades?
The functionality works perfectly on Android devices.
Having received no answers, I delved a bit deeper and discovered that...
...the tmp directory in which the images are being written is for temporary files that do not need to persist between launches of your app. Your app should remove files from this directory when they are no longer needed; however, the system may purge this directory when your app is not running. The contents of this directory are not backed up by iTunes or iCloud.
So in order for the data to persist over app updates, I need to be writing to the Documents directory
Info obtained from here
I was developing an ios application for file backup. In that I need to list and enable user to pick up files from any folder and need to do email backup like media and image picker.
I am struckup here with a bottle neck. I can't triger populating the list of document and email list for the user to pick. I had tried many codes, but it is not working.
I was working with the simulator.
Could anyone share their insight?
Regards
You should be more precise : do you want to pick up any file from any application on your device or just in your application library folder ? You can't access others applications folders.
You can find more information about the file system here :
https://developer.apple.com/library/mac/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html
iPhone do not have a file browser.
The only place that a iPhone app can take file is from photo album.
Every application keeps its files in its private place.
I need to store permanently (as far as app is not uninstalled from the device), the photos that are taken from camera roll and photo library into my app's bundle. Perviously i was storing those file in tmp folder, i read that the contents of tmp folder will be purged by iOS if it finds less memory for other app to run.. so my images were not getting displayed in my app after 3 or 4 days as IOS would have purged the content of tmp folder.
SO where do i need to Store these files? In Documents folder? is documents folder is permanent ?people say that you should not store huge amount of files in documents folder.. There is no limit for the photos that can be taken from my app. user may take 100 photos, 200photos, 500photos, or more than that.. its ok if user uninstall the application.. i will download all those photos in background once he login again. so what would you suggest for this problem? any kind of help is highly appreciated.
thanks
You put the files in the Documents folder, or if you can download them again from Internet, in the cache folder. If in Documents folder, you must mark the files with the attribute that prevents them from getting backed up to iCloud, or your app will be rejected.
Do that using this documentation:
https://developer.apple.com/library/ios/qa/qa1719/_index.html
These rules are enforced pretty vigorously by Apple and spelled out in:
https://developer.apple.com/icloud/documentation/data-storage/
(Requires iOS app developer login to view, I believe.)
What you are looking for here is SQLite. Using SQLite you can store your data and Images.
For storing the Images you can refer this link
I'm developing photo app but my app has rejected twice because of iOS Data Storage Guideline.
I don't know an exact folder which saving user's contents (In this case, user's photo taken by my app).
I guess '/Documents' could be answer, but I have no confidence.
You can save the images inside the apps document folder or can save the paths to images .
You can create you own sub directory of document i.e Documents/Photos. You can check they are saving to the correct place by enabling iTunes to access the documents folder and checking that they are being written to the correct place.