iOS Documents Directory size limit - ios

I am creating FTP download app that downloads into Documents Directory, and I have simple questions. Does the Documents Directory have size limit and does the download files stay there permanently until the app is removed?

I don't know much about this, I had seen a comment in discussions.apple.com like:
There is a limit of 2 GB.
https://discussions.apple.com/message/7599983?messageID=7599983#7599983?messageID=7599983
Files in the document directory stay there permanently until the app is removed.

============EDIT=========
the fact is: 2Gb is the app size limit, and the app's directory can more than 2Gb;
I found it from apple doc is here , search keyword "2G"
I don't know if apple did some change, I use an app named PPTV, it can store videos from server, and more than 2Gb; what happens?

You should use Cache Directory if you want to cache anything without user's action or your app will get rejected if you dont follow the instructions:
http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/PerformanceTuning/PerformanceTuning.html

Related

Create a file through a Cordova/Phonegap app that can be opened by another app (ios)?

I'm able to create and save files using cordova-plugin-file, and have been saving and accessing them from within the app to cordova.file.documentsDirectory.
The problem it seems is that all the directories that one can save to are private, Cordova-plugin-file documentation
I would like to be able to have these files saved in (or moved to) the ios blue "files" folder, so that they can be opened by other apps such as Numbers, Pages, etc. It seems so simple there has to be a way to do this, but I can't find it after more than a few evenings of searching and trying different ways.
I'd be grateful if someone could point me in the right direction.
From what I can tell you can save to the documents directory "cordova.file.documentsDirectory". By default this directory is shared with iCloud, so a file saved here could be opened through the ios File folder and a user could then select the files and hit the share icon to open with the appropriate app, such as Numbers etc.
In order to turn on iCloud you have to pay the developer fee to Apple and select the options to do so. I found the article "Working with the Files App in iOS 11" to be helpful in starting this process.
I don't have the paid developer account yet, but from what I'm reading it should work once I activate one. I'm open to a better solution or critique.

iOS application cannot access downloaded file when relaunched - UUID changes

I've been debugging a problem where my app successfully downloads a file and copies it to the Documents directory. Lately the app cannot open the downloaded file on subsequent launches of the app. I've been printing out file URLs and this is what I see when the file is initially downloaded and opened:
unzipped /var/mobile/Containers/Data/Application/9AC69C00-228E-482F-99D8-DD8F214FCE88/Documents/3.atcase to
/var/mobile/Containers/Data/Application/9AC69C00-228E-482F-99D8-DD8F214FCE88/Library/Application Support/thebundleID/current-case
You can see the UUIDs are the same, but when I launch the app again I see this:
couldn't unzip /var/mobile/Containers/Data/Application/9AC69C00-228E-482F-99D8-DD8F214FCE88/Documents/3.atcase to
/var/mobile/Containers/Data/Application/C18E7EFA-C0D0-4213-AF85-F5BC0D2A4207/Library/Application Support/thebundleID/current-case
This time the UUIDs appear to be different.
I will say tentatively that the answer is yes, the UUID used in the application container folder does seem to change every time the app is run, though I'd love to have some confirmation from a more experienced developer.
The solution to my problem was straightforward: Do not store absolute file URLs in the database. The URLs for the files are now constructed relative to the Documents directory URL every time the app is run. Since I name the files in a regular way, there is no need to store URLs anyway.

Which is permanent storage directory in iOS?

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

IOS - In-app purchase downloadable media storage guidelines

I have an app which has in app purchase downloadable videos. The first time I submitted to the app store it was rejected because I was writing it to <Application_Home>/Documents directory. The rejected reason stated that
In particular, we found that on launch and/or content download, your
app stores 20MB.
I read the guideline and it told me that
Data that can be downloaded again or regenerated should be stored in
the <Application_Home>/Library/Caches directory. Examples of files you
should put in the Caches directory include database cache files and
downloadable content, such as that used by magazine, newspaper, and
map applications.
I checked the simulator's cache directory and found that there is a default folder within the Caches folder with the name of the Bundle Id of the app. So I changed it to the following path
<Application_Home>/Library/Caches/<Bundle ID>/
Ran this in the sim and seems fine. However, when I uploaded it, it was rejected. The problem seems to come from writing the data.
Question: Is there something wrong with this directory? Should I just store it in the Caches root folder?
Thanks.

Releasing IOS app with files in Library directory

I have an app that is going to display a list of local video files. The app will only have a couple of video files at first, but that number will grow with future updates and in-app purchases. I would like to store all these videos in 1 place and it makes sense to put them in the app's Library directory so they are not user-accessible. Is it possible to publish an app with files already in the app's Library directory? Or do I have to put them in the app's bundle and then copy them to the Library directory when the app is first launched? Although that would result in the 2 videos files being duplicated since I can't remove them from the bundle.
Yes, you do need to copy the files from the app bundle into the Library if you want to treat all the videos in the same way. You cannot change the contents of the app bundle from inside your app and the only files your app has when it first launches are those that are in the app bundle.
If you really wanted (and if the video files don't change), you could make special cases in your code to be able to get the starting videos from the app bundle and the in-app purchase downloaded videos from the Library directory. But, unless the video files are quite large this seems a bit excessive.
A third option would be to have the user download the starter files on first app launch, but that may be suboptimal for other reasons.
Please look at my answer in this thread. It might concern you or at least be interesting to read.
Does updating iOS apps delete library directory files?

Resources