Skip to content

Instantly share code, notes, and snippets.

@symisc
Created March 28, 2021 02:12
Show Gist options
  • Save symisc/a4ccd7356cff9134713ad22bb8eca263 to your computer and use it in GitHub Desktop.
Save symisc/a4ccd7356cff9134713ad22bb8eca263 to your computer and use it in GitHub Desktop.
Upload a local media file using the PixLab API - https://pixlab.io/cmd?id=store
import requests
import json
# Upload a local image to the remote https://pixlab.xyz storage server or your own S3 bucket depending on the configuration from your dashboard.
# Use the output link for other purposes such as processing via mogrify, drawrectangles, etc. or simply serving content.
# https://pixlab.io/#/cmd?id=store for more info.
req = requests.post('http://api.pixlab.io/store', # Switch to http:// for fast upload
files = {'file': open('./local_image.png', 'rb')},
data={
'comment':'Super Secret Stuff',
'key':'PIXLAB_API_KEY' # PixLab API Key - Get yours from https://pixlab.io/dashboard'
}
)
reply = req.json()
if reply['status'] != 200:
print (reply['error'])
else:
print ("Upload Pic Link: "+ reply['link'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment