How to enable Move, Copy and drop in a FileProvider on iOS11?

I have a fully working FileProvider on iOS11 and I can serve up files and save them back with one exception. When I open my FileProvider in the Files.app I cannot paste or drag items into it. I get a little "not allowed" icon. If I try to Paste, the only menu option is "Info".


Also, when I save a document from an application (e.g. Word), the Move button does not appear.


I have implemented allowsAll on all my FileProviderItem objects:

var capabilities: NSFileProviderItemCapabilities {
        return .allowsAll
    }


and my FileProviderExtension implements importDocument, but it is NEVER called:

  override func importDocument(at fileURL: URL, toParentItemIdentifier parentItemIdentifier: NSFileProviderItemIdentifier, completionHandler: @escaping (NSFileProviderItem?, Error?) -> Void) {
       
        print("###\(#function): URL = \(fileURL), parentItemIdentifier = \(parentItemIdentifier)")
        completionHandler(nil, nil)
    }


I also notice that the create folder button is disabled.


What are the minimal requirements to allow new files?

Accepted Reply

Answering my own question...in case it helps someone else...


FileProviderItem should return the typeIdentifier "public.folder" for the NSFileProviderRootContainerItemIdentifier

Replies

Answering my own question...in case it helps someone else...


FileProviderItem should return the typeIdentifier "public.folder" for the NSFileProviderRootContainerItemIdentifier

How were you able to tap a file and have it actually open up the file? I'm a bit stuck at this part and got as far as being able to call startProviding item, but even though the file is downloaded, it does not show the file, instead it shows a gray view with the image name. If you don't mind sharing your sample project, that'd be great! Thanks.

Can you create folders in the root path?


How did you solve it?


Thank you

  • In addition to setting the typeIdentifier the root container must also be writable or the files app will not be able to copy files into your container even if sub folders are writable.

Add a Comment