I'd like to use Files.app
to copy a folder (e.g. from Dropbox or iCloud), then switch to my App and read the contents of this folder for further processing. I can't find a way though to get the actual data from UIPasteboard
. Calling loadObject
on the NSItemProvider
gives me an NSData
archive which I can unarchive and then get a (private) FPItem
, which implements <NSFileProviderItem>
, but what now? How can I actually request downloading the actual folder this item points to?

- 4,455
- 3
- 31
- 67
2 Answers
I've used one of my precious Technical Support Incidents (TSI) to have an Apple engineer give a statement.
The outcome is that at this point of time, copy'n'paste of a folder in Files.app
to your own app is not supported. If you want to import a folder, use a UIDocumentPickerViewController
.

- 4,455
- 3
- 31
- 67
As I understand it, you would like to download a folder from Dropbox. You may want to consider using the Dropbox API with a URLSession.shared.datatask(...)
using a REST request. If you don't want to deal with implementation details, you could use a library like SwiftyDropbox. There isn't really any need to use UIPasteboard because your end goal is downloading a folder to your app. If you would like to save said folder to the Files app, you can do so after you download/process the folder.
Here are some useful links:
- Swifty Dropbox Overview
- Swifty Dropbox Download Example
- Swifty Dropbox API Docs
- Dropbox API HTTP (RESTful Requests)
In link 2, the snippet of code below gets the directory to save the file in. One way you could get a whole folder is to (1) create a new folder in the Documents directory like this and (2) iterate through every item in the Dropbox folder and add that to the newly created folder.
let fileManager = FileManager.default
let directoryURL = fileManager.urls(for: .documentDirectory, in: .userDomainMask)[0]
let destURL = directoryURL.appendingPathComponent("myTestFile")
To implement (1), you would need to get all the files in a folder, which you can do with this /list_folder API endpoint. Then, to implement (2), you would iterate through all the files given, downloading them like in link 2.
Let me know if my answer helped, or if you need any further clarification. Thanks a bunch! :)

- 508
- 4
- 8
-
Thanks for your answer, but this doesn't solve my problem at all. The very reason for me dealing with `UIPasteboard` is to _not_ integrate any 3rdparty SDKs, but rely on the file provider extensions and drag'n'drop (iPad) / `UIPasteboard` (iPhone) to handle this in a transparent and canonical way. – DrMickeyLauer Apr 16 '18 at 08:21
-
You don’t need to use 3rd party APIs, just use HTTP requests, as provided in my answer. But if that’s not what you want, that’s okay... – Mihir Thanekar Apr 17 '18 at 04:22