Forum Archive

Access to the standard iOS Files sheet?

shinyformica

Is there a way to get access to the standard iOS Files sheet to select a file or folder from accessible locations?

I did a couple searches of the forum, but couldn't find a post about this, or anything obvious in the Pythonista libraries included with the app.

Perhaps someone has some objc_util code that can do it?

cvp

@shinyformica Not sure I correctly understand, try this

import dialogs
f = dialogs.pick_document(types=['public.item'])
shinyformica

You in no way misunderstood...and that looks like it might be exactly what I'm after. However, in my defense, that function is not documented in the docs for the dialogs module, which is where I first looked for just such an offering:

http://omz-software.com/pythonista/docs/ios/dialogs.html

But thanks for pointing me to it...I think I need to start looking at the module source before asking.

cvp

@shinyformica you're right. The on-line doc is not really up to date.
You have to use the in-app doc, by selecting a word (fi "dialogs") and tap on help.

shinyformica

@cvp thanks to you mentioning the pick_document() function, I was able to search the pythonista forum for that, and found this thread, which was informative:

https://forum.omz-software.com/topic/4815/dialogs-pick_document-with-custom-file-extensions/

That thread mentions "The internal pythonista documentation", which apparently has docs on things that might not be documented on the website? Where are the internal docs? Doing help(dialogs.pick_document) doesn't show anything useful in the console...I'm missing something, I'm sure.

cvp

@shinyformica

shinyformica

@cvp ha! You answered my question before I even asked it.

I'll do that first from now on. Thanks.

Ok, question #2, since I have you here...I'm looking over the UTI (what a poor choice of acronym...Apple) documentation and I'm not sure I see how to specify selecting a folder instead of a file...is it "public.folder"?

cvp

@shinyformica UTI not from Apple, I think
Never seen about folders, see here

shinyformica

@cvp it's an Apple-invented standard, as far as I know (https://en.wikipedia.org/wiki/Uniform_Type_Identifier)...so they are to blame for the Urinary Tract Infection...I mean Uniform Type Identifiers :)

That link is where I went to try and find the type to provide for folders...I tried both "public.directory" and "public.folder" but neither works...the files sheet shows up, but it doesn't let you select a folder.

cvp

@shinyformica it's sure that pick_document allows to pick a file, not a folder.
What do you want to do?

Even the UIDocumentPickerViewController only gets one document

JonB

If you don't need to do it programmatically, you could use Edit from the file menu, select a folder, then use the share button in the folder menu. Might not work with all apps...

cvp

@JonB That only works for folders inside Pythonista, not for folders in the Files app, isn't it?

JonB

Right.. if you are trying to share FROM files, I'd think you would need to go through the extension, and appex.get_url, but now sure how that ends up working.

cvp

@JonB I think @shinyformica wants to pick a folder in the Files app...

cvp

You can launch the Files app and Pythonista in split view, and drag a folder of the Files app and drop it into Pythonista. The folder will be copied.

shinyformica

@JonB @cvp

First, thanks for both responding!
To answer the questions you both bring up:

  1. It does need to be done programmatically, this is for picking a folder from within a running UI.

  2. The Files sheet UI definitely seems to be able to pick a folder...at least, I've seen other apps use it for that purpose. Even pythonista itself can select a folder from the Files sheet for import and other things.

If it's just that pick_document() is restricted to only picking files, and cannot pick folders, that's what I'd want to know.