Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS8: Extension storage provider(import, export, move) not work

I am developing my storage provider and use Apple’s “NewBox”(it's link was expired) sample code as the host app. Ideally I hope to see I can import(copy) files from the storage provider to my NewBox's sandbox or export/move file to other apps.

At NewBox host app, when I want to import file, I use:

UIDocumentMenuViewController *vc = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:@[(NSString *)kUTTypeRTF,(NSString *)kUTTypePNG,(NSString *)kUTTypeText,(NSString *)kUTTypePlainText,(NSString *)kUTTypePDF, (NSString *)kUTTypeImage] inMode:UIDocumentPickerModeImport];



Once I pick up a file, in my UIDocumentPickerExtensionViewController, I invoke :

- (void)pickDocument:(NSURL *)documentURL {
    [self dismissGrantingAccessToURL:documentURL];
}


After invoking dismissGrantingAccessToURL, the picker’s view will dismissed and return back to host app, and host app’s didPickDocumentAtURL will be invoked.

However, "didPickDocumentAtURL" receive the URL of the original file I selected, not the new URL that system copies to NewBox’s sandbox. This is also familiar to circumstances of export and move. Do I misunderstand the import/export/move? I thought this action about files such as copying to host app’s sandbox is done by system, and the host app will get a new URL of the file to access.

I've tried on iOS8 beta4, and this problem still exists.

Thanks!

like image 756
user3793349 Avatar asked Oct 20 '22 04:10

user3793349


1 Answers

The URL you get from documentPicker:didPickDocumentAtURL: depends on the operation:

  • Import/Export:/data/Containers/Data/Application/$(AppIDOfAppPresentingUIDocumentPickerViewController)/tmp/DocumentPickerIncoming/File.txt

  • Open/Move: /data/Containers/Shared/AppGroup/$(ExtensionAppGroupID)/File%20Provider%20Storage/File.txt

Where "File.txt" can be any file name or file path.

In case of an import, the app presenting the picker is responsible for moving the file at the given URL to a permanent location. In case of an open or move, the app should probably save the URL for future use (always use it in a a file coordinator). In case of an export, the URL is typically ignored.

The NewBox project can be downloaded from Apple's web site https://developer.apple.com/devcenter/download.action?path=/wwdc_2014/wwdc_2014_sample_code/newboxanintroductiontoiclouddocumentenhancementsinios8.0.zip

like image 97
davidisdk Avatar answered Oct 23 '22 03:10

davidisdk