Domanda

We all know you can do direct uploads to amazon S3 using a form.

See: http://aws.amazon.com/articles/1434/

I would love to replicate this functionality using an API, but without storing the uploaded file on our webserver. I know if you would stream the file through - for example - PHP, your file is stored in the TMP directory before it is uploaded to S3. But I want to avoid that.

Isn't there a way that could work like this:

  • You initiate an upload using Curl on your local system
  • Your curl request hits www.domain.com/apikey/upload/
  • the page redirects your request to a form-like page with the credentials embedded and a redirection to the right bucket with the right credentials
  • curl uploads your request directly to s3

I know this might sound far-fetched, and possibly not possible at all. But I wanted to see if someone thinks there might be a remote possibility that it could work in a way we haven't though about yet.

È stato utile?

Soluzione

Have a look at S3-Curl. It's a python wrapper that handles AWS keys and headers to properly generate the write CURL commands for the REST API for various amazon services (S3 included).

You could look inside the source of the .pl file to get an idea of how to create the curl requests yourself (only if you don't want to use s3-curl and have a restriction that you can only use curl directly).

You could use this in combination with Amazon's STS to generate a temporary token granting access for that particular upload. In this case, your modified flow would be:

  1. Initial request to domain.com/apikey/upload with parameters such as the bucket name, key for the uploaded file.
  2. Return a response with temporary credentials (through STS) only permitting upload of that particular file
  3. Use either S3 curl or curl and the temporary credentials to upload directly to S3.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top