Anonymous file upload with Python

Anonymous Files
Jan 18, 2019 · 1 min read

There are many file and image sharing web sites but we need one that allows upload via an API. provides an easy API for an anonymous file upload so lets use that. Images are hosted and displayed on the service so we can use it for file hosting too.

Below you can see an example of a CURL request to upload an image file, the API returns us the information we need to access the file upload.

$ curl -F file=@anonymous_activists.jpg
{"url": "", "id": "qZB1DXsM", "name": "anonymous_activists.jpg", "size": 114230, "mime_type": "image/jpeg"}

So now we can translate the CURL request into Python using the requests library.

import requestsr ='', files={'file': open('/Users/myself/anonymous_activists.jpg', 'rb')})print(r.text)#{"url": "", "id": "qZB1DXsM", "name": "anonymous_activists.jpg", "size": 114230, "mime_type": "image/jpeg"}

We grab the url param from the response and we can see our image uploaded and hosted in all its glory.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store