10

Amazon has instructions on how to write a form that posts directly to Amazon's S3 service via HTML POST. However, they are not very clear on how to create a simple form to upload directly to an S3 bucket, and never give an actual example html file.

Is there a good example available where I can view the sample code?

starball
  • 20,030
  • 7
  • 43
  • 238
chris
  • 20,791
  • 29
  • 77
  • 90
  • The downloadable example here has a nice php class for creating and signing the policy (the "Policy" and "Signature" fields required by the form). http://aws.amazon.com/code/1618?_encoding=UTF8&jiveRedirect=1 – rangfu Feb 17 '11 at 17:01

4 Answers4

6

Here is a piece of html code from the aforementioned doc. I think it's self explanatory but let me know if you're having any troubles.

  <form action="http://johnsmith.s3.amazonaws.com/" method="post" enctype="multipart/form-data">

    Key to upload: <input type="input" name="key" value="user/eric/" /><br />

    <input type="hidden" name="acl" value="public-read" />

    <input type="hidden" name="success_action_redirect" value="http://johnsmith.s3.amazonaws.com/successful_upload.html" />

    Content-Type: <input type="input" name="Content-Type" value="image/jpeg" /><br />

    <input type="hidden" name="x-amz-meta-uuid" value="14365123651274" />

    Tags for File: <input type="input" name="x-amz-meta-tag" value="" /><br />

    <input type="hidden" name="AWSAccessKeyId" value="15B4D3461F177624206A" />

    <input type="hidden" name="Policy" value="POLICY" />

    <input type="hidden" name="Signature" value="SIGNATURE" />

    File: <input type="file" name="file" /> <br />

    <!-- The elements after this will be ignored -->

    <input type="submit" name="submit" value="Upload to Amazon S3" />
Alex
  • 511
  • 3
  • 5
  • thanks for the message Alex. I got it work. Do you know if this can be implemented using swfupload? If so, is there any sample code anywhere I could get? I've tried googling but no luck – chris Sep 06 '09 at 03:03
  • hi, i just want to ask if its possible to upload in s3 using only temporary credentials? – Wondering Coder Oct 09 '13 at 10:35
1

Browser-Based Uploads Using POST to Amazon S3

Community
  • 1
  • 1
410
  • 3,170
  • 8
  • 32
  • 36
1

The current documentation for POST on S3 explains it very well. (This thread is a bit dated)

alecco
  • 2,914
  • 1
  • 28
  • 37
0

There is one very basic upload utility using swfupload. https://github.com/cyberbuff/ZenS3

Disclaimer: I developed it.

abhisek
  • 924
  • 1
  • 13
  • 27