Uploading files via requests

Upload API helps you upload files by making POST requests to, via HTTPS,

https://upload.uploadcare.com/base/

In short, it goes like POST /base/.

Query parameters

UPLOADCARE_PUB_KEY, string

Defines a project to which your uploads go to via its public key.

UPLOADCARE_STORE

Sets the file storing behavior. Once stored, files are not deleted after a 24-hour period. Accepted values are:

  • 0 or not set — files do not get stored upon uploading.
  • 1 — files get stored upon uploading. Requires the “automatic file storing” setting to be enabled.
  • auto — file storing works in line with your project settings.

(other)

Files as form data, any field names will do.

Response

In response, you get a JSON dictionary where keys correspond to file field names, and their values are the respective file UUIDs. Here is an example,

Request:

curl -F "UPLOADCARE_PUB_KEY=demopublickey" \
     -F "UPLOADCARE_STORE=1" \
     -F "file=@image.jpeg" \
     "https://upload.uploadcare.com/base/"

Response:

{
  "file": "17be4678-dab7-4bc7-8753-28914a22960a"
}

We’re always happy to help with code, integration, and other stuff. Search our site for more info or post your question in our Community Area.