omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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

    Pythonista
    2
    5
    1743
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • cvp
      cvp last edited by

      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

      1 Reply Last reply Reply Quote 0
      • cvp
        cvp last edited by

        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 1 Reply Last reply Reply Quote 1
        • cvp
          cvp @cvp last edited by

          @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.

          1 Reply Last reply Reply Quote 0
          • ChelsWin
            ChelsWin last edited by ccc

            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.

            cvp 1 Reply Last reply Reply Quote 0
            • cvp
              cvp @ChelsWin last edited by

              @ChelsWin said:

              Would it be possible to force download all the music

              No idea, sorry.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Powered by NodeBB Forums | Contributors