Extensión Del Proveedor de Archivos, ImportDoc... - Foros para Desarrolladores de Apple

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

File Provider Extension,

importDocumentAtURL:: can't
read file at given URL (iOS 11.4.1)
I'm having troubles with Paste opertaions into my containers in File
Provider extension.

If I paste copied image or text into Files app -> My App -> any folder
the file at fileURL can not be read (as a result can't be uploaded to my
servers nor stored locally).

- (void)importDocumentAtURL:(NSURL *)fileURL
toParentItemIdentifier:(NSFileProviderItemIdentifier)parentItemIdentifier
completionHandler:(void (^)(NSFileProviderItem _Nullable importedDocumen
{
NSError *readError = nil;
NSData *fileData = [NSData dataWithContentsOfURL:fileURL options:NSDataReading
NSString *readErrorMessage = readError.localizedDescription;

NSURL *myFileURL = [NSFileProviderManager.defaultManager.documentStorageURL UR


NSError *copyError = nil;
BOOL copyResult = [_fileManager copyItemAtURL:fileURL toURL:myFileURL error:&c
NSString *copyErrorMessage = copyError.localizedDescription;
...

copyResult is false, both readErrorMessage and copyErrorMessage are:

The file “text.txt” couldn’t be opened because you don’t have


permission to view it.
:
What am I doing wrong here?

This happens to any file copied from my container, iCloud container, as


well as synthetic files produced from text/image/other data from
system Clipboard.

For emalple, fileURL for image.png file I'm trying to duplicate from my
own container is

file:///private/var/mobile/Containers/Data/Application/80480715-574A-
4E99-B588-FBDCC7F1FDFC/tmp/DDBD7C7B-56C0-4F61-94A9-
109613C78F75/image.png/

The same time the item being duplicated is located at:

file:///private/var/mobile/Containers/Shared/AppGroup/A8C1416D-
8435-407E-82B3-
CE10A8439630/File%20Provider%20Storage/Document93838429/im
age.png

I guess I cant ready anything in


/private/var/mobile/Containers/Data/Application/80480715-574A-
4E99-B588-FBDCC7F1FDFC/

Thanks.
:

You might also like