Posts

Post marked as Apple Recommended
44k Views
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 importedDocumentItem, NSError * _Nullable error))completion { NSError *readError = nil; NSData *fileData = [NSData dataWithContentsOfURL:fileURL options:NSDataReadingMappedAlways error:&readError]; NSString *readErrorMessage = readError.localizedDescription; NSURL *myFileURL = [NSFileProviderManager.defaultManager.documentStorageURL URLByAppendingPathComponent:@"temp.dat"]; NSError *copyError = nil; BOOL copyResult = [_fileManager copyItemAtURL:fileURL toURL:myFileURL error:&copyError]; 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 isfile:///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/image.pngI guess I cant ready anything in /private/var/mobile/Containers/Data/Application/80480715-574A-4E99-B588-FBDCC7F1FDFC/Thanks.
Posted
by GrigUA.
Last updated
.