Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular.js and Amazon S3 - How to Upload files?

I have an application in Angular.js. In the truth, I made an update in my old site, changed that for Angular.

In old version, I was using Uploadfy jquery component for my uploads in Amazon S3. But now, with Angular, I can't use this.

I want to use the directive "ngUpload". But I don't know how to do this. Anybody can help-me?

like image 845
Eduardo Avatar asked Apr 19 '13 12:04

Eduardo


People also ask

How do I upload files to Amazon S3?

In the Amazon S3 console, choose the bucket where you want to upload an object, choose Upload, and then choose Add Files. In the file selection dialog box, find the file that you want to upload, choose it, choose Open, and then choose Start Upload. You can watch the progress of the upload in the Transfer pane.


1 Answers

You can upload directly to an S3 bucket from an HTML form if you include valid S3 parameters in your POST data. These are called pre-authorized HTML POST forms.

The valid parameter values are generated on your own hosting server through an API call to the AWS API. The values are then added to your upload form as hidden input fields.

Here's what they look like in your form:

  <input type="hidden" name="AWSAccessKeyId" value="YOUR_AWS_ACCESS_KEY"> 
  <input type="hidden" name="acl" value="private"> 
  <input type="hidden" name="success_action_redirect" value="http://yourdomain/">
  <input type="hidden" name="policy" value="YOUR_POLICY_DOCUMENT_BASE64_ENCODED">
  <input type="hidden" name="signature" value="YOUR_CALCULATED_SIGNATURE">

Amazon provides sample code for Java, Python and Ruby.

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

like image 145
Peter Drinnan Avatar answered Sep 20 '22 20:09

Peter Drinnan