Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Force a Pythonista iCloud file to be locally downloaded before accessing it
-
If you try to access a Pythonista iCloud file when it is not yet downloaded on your
local device, you get an access error.You can force a Pythonista iCloud file to be downloaded by this small code:
from objc_util import * path = '/private/var/mobile/Library/Mobile Documents/iCloud~com~omz-software~Pythonista3/Documents/Mes Pastels/Mes Pastels.pdf' url = nsurl('file://' + path.replace(' ','%20')) NSFileManager = ObjCClass('NSFileManager').defaultManager() ret = NSFileManager.startDownloadingUbiquitousItemAtURL_error_(url, None) print(ret) # True if ok
Files app: iCloud Drive/Pythonista/My folder before
Files app: iCloud Drive/Pythonista/My folder after
-
This script also downloads a selected file
import dialogs #import shutil fil = dialogs.pick_document(types=['public.item']) print(fil) #shutil.copy(fil,'test')
-
@cvp said:
This script also downloads a selected file
But the url (path) it returns is pointing to a copy of the file, not to the real file.
Thus, useless for saving a file. In this case, only UIDocumentPickerViewController can do it. -
That's handy. Would it be possible to force download all the music I have brought through the iTunes Store into the music app somehow? Right now I am having to download albums individually and it would be really neat if I could download them all with a Python script.
-