Skip to content

Instantly share code, notes, and snippets.

@sebietter
Created February 11, 2013 14:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sebietter/4754591 to your computer and use it in GitHub Desktop.
Save sebietter/4754591 to your computer and use it in GitHub Desktop.
With this script for Pythonista you can easily upload a picture from iOS to your own webserver.
import webbrowser
import clipboard
import Image, ImageFile
import datetime
import ftplib
import urllib
from io import BytesIO
today = datetime.datetime.now()
image = clipboard.get_image()
fileName = 'picture_iOS'
fileName = fileName + '_' + today.strftime("%Y-%m-%d-%H%M%S") + '.png'
urlBase = 'YOUR BASE URL'
encodedFileName = urllib.quote(fileName)
print fileName
buffer = BytesIO()
image.save(buffer, 'PNG')
buffer.seek(0)
ftp = ftplib.FTP('YOUR FTP SERVER', 'YOUR LOGIN', 'YOUR PASSWORD')
ftp.storbinary('STOR '+fileName, buffer)
ftp.quit()
clipboard.set(urlBase + encodedFileName)
print 'Success! The link to your uploaded picture is now in your clipboard.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment