A few months ago I wrote a post about creating Amazon S3 HMAC Signatures without PEAR or PHP5. One of the things I was using that PHP script for was to feed the necessary information to a bash script hosted on a remote machine. The bash script was to upload a file via POST to Amazon S3 using the information provided.
Since CURL was already installed on the remote machine, I wanted to use that to do the actual uploading. I found very little help on the net regarding how to do this with CURL so here you go:
eris:~ raam$ curl \ -F "key=screenshots/current_screenshot.jpg" \ -F "acl=public-read" \ -F "AWSAccessKeyId=2EO6H8MX1X8YWEA0V432" \ -F "Policy=eyAiZXhwaXshdGlvbpI6ICIyMDA4LTErLTAxVDtyOjAwOjAwLjAsMFoiLAogICJjb25kaXRpb25zPjogWwoJeyJidWNrZXQiOiAiczNwaG90b3MubW9hcHAubmV0IiB9LAogICAgWyJzdGFydHMtd2l0aCIsICIka2V5IiwgIkxpdmVTaG90cy8iXSwKICAgIHsiYWNsIjogInB1YmxpYy1yZWFkIiB9LAoJWyJlcSIsICIkQ29udGVudC1UeXBlIiwgImltYWdlL2pwZWciXSwKICBdCn0K" \ -F "Signature=20uh08kU75ADHL49NyhYRgZW8BY=" \ -F "Content-Type=image/jpeg" \ -F "file=@current_screenshot.jpg" \ http://screenshots.ekarma.net
Keep in mind this assumes the current_screenshot.jpg file is in your current directory.


How did you get the “Policy” number?
I was able to get other information from the firebug.
See my other post; it describes how to generate the Policy: http://blog.raamdev.com/2008/05/03/amazon-s3-hmac-signatures-without-pear-or-php5/
Thanks for this usefull post.
I’m trying to remove a file from s3. Would it work if I include ‘-X DELETE’ in the request?
Thanks
Hi Maryam,
Its been awhile since I’ve used the AWS API, so I can’t tell you off the top of my head. The answer can be found in the API docs on Amazon’s website.