Skip to content

Instantly share code, notes, and snippets.

@dmora
Created March 9, 2015 01:26
Show Gist options
  • Save dmora/03391e00a327396eca97 to your computer and use it in GitHub Desktop.
Save dmora/03391e00a327396eca97 to your computer and use it in GitHub Desktop.
Upload local file with python to filepicker using their REST API
from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
import urllib2
register_openers()
datagen, headers = multipart_encode({"fileUpload": open("filaname.jpg")})
request = urllib2.Request("https://www.filepicker.io/api/store/S3?key={yourKey}", \
datagen, headers)
response = urllib2.urlopen(request)
print urllib2.urlopen(request).read()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment