UploadCare provides a RESTful API for dealing with your files and other operations. The API protocol and resources are described in this document.
UploadCare API is REST over HTTP. The base URI is http://api.uploadcare.com/.
Every request to API should be signed.
API supports different content types, including json and xml. You should use Content-Type header for indicating in which format you’d like to send or receive data.
You can play with API in your browser - just open any resource url, like http://api.uploadcare.com/files/ .
To make a request to http://api.uploadcare.com/, you should sign it with your own public and private keys. This is done in several steps:
Fri, 09 Nov 2001 01:08:47 -0000
This can be done, for example, via standard Python library function: email.utils.formatdate(usegmt=True). The date should be within ~15 minutes of our server time at the time of your request.
'\n'.join([verb, # an http verb, like 'GET' (uppercase)
content_md5, # an md5 hash of the request contents
# if you're sending empty request (for example, using GET), use md5('')
content_type, # contents of your Content-Type header, like 'application/json'
date, # date from the step 1
uri]) # request uri, like '/files/some-file-id/'
import hmac
import hashlib
hmac.new(str(secret),
sign_string,
hashlib.sha1).hexdigest()
I’ve actually stolen this algorithm from S3 specification. Probably I’ve overengineered it a bit. I should think more.
You can take a look at the Python implementation.
You can’t create files with this. Please use upload for that.
Collection URI: http://api.uploadcare.com/files/
Element URI: http://api.uploadcare.com/files/<file_id>/
In both cases (list and particular file), the file structure looks like this:
{
"file_id": "d1675406-64aa-4bd5-8b89-7bcbafd10125",
"last_keep_claim": "2012-05-04T05:26:57.886",
"made_public": true,
"mime_type": "image/jpeg",
"on_s3": true,
"original_file_url": "http://s3.amazonaws.com/uploadcare/d1675406-64aa-4bd5-8b89-7bcbafd10125/20120503211528.jpg",
"original_filename": "20120503211528.jpg",
"removed": null,
"size": 177808,
"upload_date": "2012-05-04T05:27:03.136",
"url": "http://api.uploadcare.com/files/d1675406-64aa-4bd5-8b89-7bcbafd10125/"
}
Just a list of problems we’ve noticed to appear frequently: