Editorial Workflows

SFTP Upload

unlisted workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: :::Works on currently open text file:::

:::Uploads current editor file to an SFTP host as a MD file.:::

:::Must edit script to include your own SFTP host connection details.:::

Shared by: http://www.macdrifter.com/2013/08/editorial-sftp-workflows.html

Comments: Comment Feed (RSS)

Yar — 12 Mar 2016
Awsom, exactly what I want

+ Add Comment

Workflow Preview
Get Current File Name ?
Include Folder
OFF
Include Extension
OFF
Set Variable ?
Variable Name
postTitleVar
Value
Input
If… ?
Run the block if
postTitleVar
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Run Python Script ?
Source Code
import workflow
import editor
import console
import keychain
import pickle
import paramiko

#keychain.delete_password('macdrifter', 'editorial')
login = keychain.get_password('macdrifter_ssh', 'editorial')
if login is not None:
	user, pw = pickle.loads(login)
else:
	user, pw = console.login_alert('FTPS Login Needed', 'No login credentials found.')
	pickle_token = pickle.dumps((user, pw))
	keychain.set_password('macdrifter_ssh', 'editorial', pickle_token)





remote_path = "/remote/file/path/"
host = "your.host.com"
port = 22

file_name = workflow.get_variable('postTitleVar')
file_path = editor.get_path()


try:

	transport = paramiko.Transport((host, port))
	transport.connect(username=user, password=pw)
	sftp = paramiko.SFTPClient.from_transport(transport)
	#sftp.chdir(remote_path)
	sftp.put(remotepath=remote_path+file_name+'.md', localpath=file_path)

	sftp.close()
	transport.close()
	console.hud_alert(file_name + '.md uploaded', 'success')

except Exception, e:
	print e
	console.alert('Error', e)
…End If