iTunes file sharing - how to upload different folders? - iphone

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.

Related

Imported packaged files ".key .numbers .pages" from iCloud using UIDocumentMenuViewController are not opening in UIWebView

Hi I am trying to display a packaged file say .key/.pages/.numbers file to user in a UIWebView but I cant. The keynote file was created using a Keynote app from my iPad recently. I imported that file to my app using UIDocumentMenuViewController from iCloud. I tried to look into the file attributes and it turn out that the file imported is actually a "directory" not single file. Inside, it has some contents. Can anybody tell me how to go from here?
I had the same problem. iWork files are zipped bundles but for some reason importing from iCloud unzips the contents first, whearas copying from the app directly via Open in ... from Number (or Pages or Keynote) works perfectly.
So what you need to do is test if the result of import is a directory, and if so zip the directory into a single file and keep the correct file extension (.number pages or .key).
This seems like a hack but it works and is best workaround I've been able to find
In Swift you can use SSZipArchive as an easy way to zip a directory

How can I exclude a file from iTunes file sharing?

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.

iOS - Allow user to download file from documents directory but not to upload file using iTunes

Here is a situation I have a data file in document directory which is being updated in the application every now and then. So I want to save it to my desktop using iTunes. But I don't want that the file should be uploaded back to my application. i.e. I want that user can download the file but can not upload any.
I was thinking to have the data file on some other location like Library and put a button on application settings saying "Prepare backup" that will copy that data file in Document directory, from where user can download it. If user uploads any thing it won't make any difference as my current file is in Library directory.
This is just a thought,
can anyone suggest me other way or the above way is good to go?
Edit: I just need that after the successful export user can view the data file (may be later) without support of the application.
You can't.
But what you can do is check (using an timer every 10 seconds) if a new file is added to the documents directory and then delete it programmatically.
But this ofcourse doesn't disable the replacement of files.

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.

Documents/Inbox folder for opening file from another App

I registered my app to associate some filetypes. so when the file comes in the mail attachment, I use my app to open the file. My app will automatically create a "Inbox" folder inside my Documents folder, and save the file in "Inbox". This Inbox is special, because it prevents me to create a folder or move a file into it by program.
Question comes to me is:
What is the special for the "Inbox"? Can I change some setting, and
it will allow me to create a subfolder inside?
What is normal solution for this?
Thanks
Cullen
Inbox is just a link to your email stuff. You should copy the files from there to your documents directory withNSFileManager.