【发布时间】:2018-09-06 07:30:16
【问题描述】:
我在文件提供程序扩展中将粘贴操作粘贴到我的容器中时遇到问题。
如果我将复制的图像或文本粘贴到文件应用程序 -> 我的应用程序 -> 任何文件夹中,则 fileURL 处的文件无法读取(因此无法上传到我的服务器或本地存储)。
- (void)importDocumentAtURL:(NSURL *)fileURL
toParentItemIdentifier:(NSFileProviderItemIdentifier)parentItemIdentifier
completionHandler:(void (^)(NSFileProviderItem _Nullable importedDocumentItem, NSError * _Nullable error))completionHandler
{
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:©Error];
NSString *copyErrorMessage = copyError.localizedDescription;
...
readErrorMessage 和 copyErrorMessage 都是:
无法打开文件“text.txt”,因为您没有查看权限。
我在这里做错了什么?
谢谢。
UPD:从我的容器、iCloud 容器复制的任何文件以及从系统剪贴板中的文本/图像/其他数据生成的合成文件都会发生这种情况。
【问题讨论】:
标签: ios objective-c fileprovider-extension