Does iOS devices deletes images picked by ImagePicker (Flutter) over time? - ios

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.

Related

How do you persist image references across app updates on iOS devices

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

How to copy photo in device's photo gallery to local path

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.

Clear cache for particular app in iPhone settings

I am developing an iOS Application like Flipkart. So, I want to show many images on my dashboard.
Every image was downloading in URLSession at every time app is open.
So, I used NSCache to save some category of images.
And also used local temp folder to save some images.
My TL asked me to clear all cache images like android app.
How to clear cache in settings?

Keeping images in sync with web server in iOS with regards to foto stream

Simple scenario: I like to synchronize images on my server with an iOS app. The app regularly gets a list of image resources and downloads these to the iOS photo album / creates PHAssets. The app stores both the PHAssets fresh localIdentifier and the resource url with core data. It will not download these images again. Let's say this is happening on my iPhone and on my iPad. Let's say both devices ran these synchronisation jobs and are 100% in sync with my webserver.
And here is the catch: the iOS foto stream will produce a copy of each downloaded image on the respective other device - once it had enough time to do its own syncing. I will end up with duplicates on both devices.
Is there any way to prevent this from happening?
I guess, it should be PHAsset's property "originalFilename". If I set this to a globally unique identifier, I can recognize files, which have already been downloaded to this device.

Delete all local Images and videos taken using UIImagePickerController from the app ios swift

I am using the UIImagePickerController to take Images and videos for the App.
What i need to ensure is the app takes minimum storage. So as soon as i have taken the image/video i upload it to my server so that i can access it using a url now.
Thus what i need is whenever the app terminates , i want to clear all the images and videos taken , so as to ensure less memory is consumed.
Please note that i do not want to delete the file immediately after uploading. I know how to delete a file from a directory individually.
Kindly suggest some other approach if I am wrong.
no guarantee that applicationWillTerminate will ever get called may that is the reason you can not do that (Thus what i need is whenever the app terminates , i want to clear all the images and videos taken , so as to ensure less memory is consumed.) . so if your need to do anything before app exist then call applicationDidEnterBackground
but you can try on trick for that
Local notification on application termination
Update :
How to save images from Camera to specific folder in iPhone gallery?
and
Delete files in iOS directory using Swift
How to delete ALL FILES in a specified directory on the app?

Resources