How can I exclude a file from iTunes file sharing? - iphone

iTunes file sharing works by exposing all the files in /Documents
But I would want to explicitly exclude certain files. Is this possible?
UPDATED:
Specifically, one of my ad network SDK is storing a mraid.js in Documents.

If you don't want a file shared, don't store it in the Documents folder. Use the Application Support folder for example.
Another option is that iTunes won't show any files or folders from the Documents folder that start with a dot. You could rename the files you don't want to share with a dot or put them in a subfolder whose name begins with a dot.

Try looking at This Question. Also, depending on what you are storing, you can try using the NSUserDefaults instead.

There is no way to exclude files from File Sharing.
The files you need to share should be put under Documents directory and the files which you don't want to share should be kept in other directories. It'll solve the issue.

Related

How to group files according to formats in folder structure in iOS app?

I'm trying to make an app where I can group different files in their respective folders from two accessed servers. For example all pictures from two servers should be in Picture folder and all music files in Music folder of the app.
As I have to access all the files from the server how could I group all the files in above mentioned folders.
Any suggestions how to initiate from above situation
Generally interactions with the app's sanboxed file system are done via the NSFileManager class.
http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html
That class allows you to move, copy, delete, etc... You'll likely want to use it to first create your two directories, then use it to save files into those directories as needed.

UIFileSharingEnabled use folders

I want to allow users add files to the application document folder, so I used the iTunes file sharing. The problem is they can only add single files with a flat structure. I want to drag and drop whole folder (even with sub folders) and keep the structure.
Questions I have:
is it possible with iTunes file sharing?
if not, is there an open source project that helps me with writing a pc side app that talks to the iPhone side app and pushes the files into it?
No you can't add Folder's/sub folders, iTunes will show just the files in the documents root. I think the only way to do that is to add it as zip file and you extract it in your app.
Maybe CocoaHTTPServer will help you.

Is it possible to limit iOS file sharing functionality to a subfolder in the documents directory?

My image editing app is saving some important data in the documents directory. In a tutorial I was reading this:
iTunes will then display anything you
save to the Documents directory in
your app to the user, when they go to
the “Apps” page in iTunes and scroll
to the bottom:
I have a subfolder called userImages and it would be clever to restrict file sharing only to that folder and not to everything in documents. Otherwise the user would accidently (or on purpose) mess around with files that the app depends on to work properly. This would be bad.
Is there a way to restrict it to a subdirectory in documents?
No, what you should do instead is store anything you do not want users seeing in the "Library" directory for the app. Check here for a list of places you can store data:
How can I get a writable path on the iPhone?

iTunes file sharing - how to upload different folders?

i want to use the "file sharing" feature in my app. I want to create a photo-app which has no content when the user starts it. Therefore the user can select an image-folder on his mac or pc. After that and starting the app on his iphone or ipad, all the content of his image-folder will be viewable.
I think its only possible to add simple files to my app - not content folders, right?
Any ideas how i could do this?
Thanks for your time and help.
On your mac, rename the folder to folder.pkg.
You can now add folder.pkg to the documents for your app using iTunes File Sharing.
Once folder.pkg has been added, rename it to its original name.
Not sure how to do this with iTunes on a PC.
You cannot upload folder to the app.
one way to do so
create .zip file of that folder and upload.
extract that zip file from app.
checkout this project, It has a code to extract zip file.
https://github.com/ZipArchive/ZipArchive
I found that using iTunes 12, and iOS8, I can now ADD folders to an apps Documents folder using iTunes File Sharing. Previously it was only possible to add single files.
It is indeed possible to add a folder to and App's File Sharing space using iTunes version 12+. However, the iTunes upload button will not work for this, because its file selection interface insists on plain file selection only, excluding folders. The way which works is to drag-and-drop a folder from your PC to the iTunes File Sharing window.
Since the iTunes interface for handling file sharing is very poorly designed, is is worth recalling the tricks that you can use to perform operations on the File Sharing space, that iTunes does not provide a button for:
Rename a file or folder: click it once, wait for a couple of seconds, and click it again. This will replace the name with the renaming edit box
Delete a file or folder: select it, then hit the "Del" key on your keyboard
Upload a folder: drag-and-drop it from your computer copy
It remains impossible to directly see or alter the contents of a File Sharing folder in iTunes. My workaround for doing this is the following:
Download the folder to the computer
Make any desired change to the folder tree on the computer copy
Delete the File Sharing copy of the folder (or, optionally, rename it to something like folder.old for safety)
Upload the modified folder from the computer, using drag-and-drop
(optionally) Delete the safety copy in File Sharing, after verifying that the App works fine with the newly uploaded version of the folder
I hope this helps
I was not able to drag-and-drop a folder from my PC (Windows 10). But I found a free application called iFunbox that allowed me to copy a folder to an application's documents.

How can I download an entire directory?

Is it possible in Objective-C to download an entire directory to the documents directory so I would end up with a subfolder in the documents directory with a name of my choosing? Then, is it possible to delete that directory and all its contents without looping through all the files? Many thanks in advance.
The short answer is 'Yes, its possible' given that the directory and files in question are not larger than the available space on the device. If you are talking about some text files or some images then I don't see a problem.
Not so sure about deleting all the contents without first getting a pointer to the files but that shouldn't take long in any case.
Were you looking for specific code examples as well?
There is a similar question, and answer [here].1
You cannot download entire folders over the internet, you would have to list the files and download them one by one.
You can use NSFileManager to create, read and remove files in your apps folder. You can delete a complete folder without having to loop through all the items in the folder.
(BOOL)removeItemAtPath:(NSString )path error:(NSError *)error;
Have a look at the NSFileManager documentation:
NSFileManager documentation
Keep in mind that whenever you go outside the "sandbox" of your app, your app will be rejected by apple. So keep those files within your app's bundle.