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.


    How to get a "text" file from iCloud Drive

    Pythonista
    2
    4
    7243
    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 cvp

      If you want to get a "text" file (py,txt,...) from iCloud Drive to Pythonista via the ios File Picker, and if you have the Workflow app, you could:

      • create once a Workflow, for instance GetFileFromIcloudDrive, containing only these two actions:
        • Get Files
          • Show Document Picker on
        • Set Variable File (will contain the entire file)
        • Get Details of file
          • Get Name
        • Set Variable FileName (will contain the file name)
        • Get Variable File (neded for the next action)
        • Get Details of file
          • Get File Extension
        • Set Variable FileExtension (will contain the file extension)
        • Set Text
          GetFileFromIcloudDrive:variable_FileName.variable_FileExtension
          File
        • Copy to Clipboard
          see Workflow

      When you're "in" the File Picker, you can even get a file from another location, like Google Drive, OneDrive, etc...

      • run this script
      import webbrowser
      import clipboard
      import time
      
      # Get a text file from iCloud Drive via File Picker
      def get():
      	clipboard.set('')
      	webbrowser.open('workflow://x-callback-url/run-workflow?name=GetFileFromIcloudDrive&x-success=pythonista://')
      	text = clipboard.get()
      	while text.find('GetFileFromIcloudDrive') < 0:
      		text = clipboard.get()
      		time.sleep(0.3)
      		# Clipboard should be formatted as:
      		# 	GetFileFromIcloudDrive:filename.ext\n
      		# 	file_content
      		i = text.find('\n')
      		if i > 0:
      			line1 = text[0:i]
      			filename = line1[len('GetFileFromIcloudDrive:'):]
      			print('/'+filename+'/')
      			file = text[i+1:]
      			locfil = open(filename,'w')
      			locfil.write(file)
      			locfil.close()
      			
      get()
      
      1 Reply Last reply Reply Quote 0
      • deloriel42
        deloriel42 last edited by

        good idea, did you post that scripts on github?

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

          two possibilitie improvements:

          • use (new) magic variables in workflow wFlow
          • pass json object to pythonista
          1 Reply Last reply Reply Quote 0
          • cvp
            cvp last edited by cvp

            No sorry, nothing posted on Github
            I don't use anymore Workflow, I only use Pythonista with which I can do all what I want, with a better ui.
            You can import any file from anywhere in Pythonista.

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