« Important Information on Maptacular | Main | Apollo (now AIR) Sample Applications »

May 30, 2007

ActionScript Library for Amazon S3

I've been working on an Amazon S3 client in Apollo, and I finally got around to extracting the S3 library and making it its own project. I put it up on Google Code under the name as3awss3lib.

The library will only work in Apollo because there are too many restrictions in the browser player for it to work. Since I knew it wouldn't work in the browser anyway, I went ahead and used some Apollo APIs. It also has dependencies on As3Crypto, as3corelib, and Flex (you can use the free Flex SDK).

I haven't implemented everything S3 supports yet. Specifically, I haven't implemented access control (everything is private) and the bucket listing pagination functionality. But all the hard protocol work is there so the rest is easy to add. Right now, you can:

I'll release the application I'm building on top of the library as soon as we update the public release of Apollo. It allows you to drag and drop and copy and paste files to and from S3.

Posted by cantrell at May 30, 2007 8:46 AM

Comments

Great, yet another good stuff from you man... Thanks for making it open-source...

-abdul

Posted by: Abdul Qabiz at May 30, 2007 10:24 AM

Also just saying tanks! :-)

Posted by: Morten Reinholdt at May 31, 2007 12:09 AM

Hey Christian,

The link to Free Flex Lib on the google page is broken.

Posted by: Keith at May 31, 2007 3:06 AM

Hi - the as3awss3lib appears to be missing from Google Code/ Can you pop it back up sire?

thanks,
biffer

Posted by: Biffer Rowley at June 12, 2007 3:23 AM

salsa is my friend...would LOVE to have public URL and access control as top two added features -- thanks christian!

Posted by: timheuer at June 12, 2007 4:15 PM

Dope! I was wondering if someone took initiative for this yet. Thanks Christian.

Posted by: Chris Charlton at June 13, 2007 4:12 PM

Biffer, the project is located here:

http://code.google.com/p/as3awss3lib/

Keith, there was actually a bug in the Google Code site that broke several links (they were adding an additional "http" to the beginning. I've fixed them.

Tim, I'll add these features for the next release.

Christian

Posted by: Christian Cantrell at June 14, 2007 6:13 AM

I ran across your library while researching use of AWS S3 from browser Flash player. I'm new to Flash and S3. You mention that there are too many restrictions on the browser player for as3awss3lib to work in that env. Is it impossible to access S3 from broswer Flash? or are there certain operations that are possible?

Thanks!

Posted by: Jonathan at July 6, 2007 8:39 PM

Hello Christian,

I would like to create an AIR uploader so I took your source code but there a probleme with the assw3 libs when I try to compile your application, the error is that "The name of the definition 'com.adobe.webapis.AWSS3Event:AWSS3Event' must match the path of the files AWSS3Event and AWSS3.
Could you give me the solution?
Thank you very much and congratitulation for your hard work on this project.

Chris

Posted by: Chris at July 12, 2007 8:09 AM

The download link on the Google page seems to have disappeared again.

I can download the dependent projects without any problem.

Can you fix this? Thanks...

Posted by: Bernard Farrell at July 18, 2007 12:48 PM

I'm curious about the restrictions that require Air to use S3. Are you sure it's not possible without Air?

Posted by: rob at August 24, 2007 4:58 AM

Regarding the previous post, I'm just interested in uploading, not downloading with actionscript without Air. There's an Ajax solution that's kind of interesting called S3Ajax.

Posted by: rob at August 24, 2007 5:21 AM

Now that Flex Builder 3 is out is there any chance we can get an update so that we can set the access control?

Thank you for making such a handy library,
-Dan

Posted by: Dan at October 9, 2007 7:20 PM

What a great flex utility. I'm using it to secure a xmpp data in an instant messaging client.
http://www.friendlytek.com/vim

Keep up the good work.

Posted by: Flex Ajax at October 20, 2007 9:38 PM

is there a way to change the acl by uploading a file??

please help me ( contact me by email )

thx

Posted by: markus at October 24, 2007 1:44 AM

Hi!

I was wondering what happened to the Salsa Demo? It's no longer listed on the Gallery/Sample Applications.

I noticed that with the latest Flex Builder 3 (M4 Beta 3) it says that "shouldCacheResponse" property in the getURLRequest() method in AWSS3.as does not exist. (Around line 331).

After commenting it out to get it to compile I noticed that there's now an i/o error with the ID 2038. Any suggestions as to what might be the problem?

For those looking to do ACL there's a document on Amazon suggesting that you change the requestHeaders so one way might be to do: req.requestHeaders.push(new URLRequestHeader("x-amz-acl", "public-read"));

I'll confirm this as soon as I can get the library to work in FB 3.

Thanks!
-Dan

Email: danprime at gmail

Posted by: Dan at December 18, 2007 2:57 PM

Yo, yo! ;) Finally I found what I need. Thanks ;)

Posted by: music lover at December 29, 2007 4:59 AM

Hello,

Thanks for the jump start, we needed this functionality for a client app, but as was mentioned somewhere else, if your app is for clients who will use your s3 account, it's not good to provide the secret key in your app. Also, any news on what happened to Salsa?

I have been working on rewriting some of the functions in your library to instead use a php web service to authenticate the key, then the AS3 library can complete the direct upload to S3. This allows for management by our server of what gets put in our S3 account without having to receive the file upload and transfer to S3, the AIR app can upload direct to S3.

I am wondering if you would like to include this into your Google library as I'm sure others creating AIR apps will need this functionality. I am also receiving that same 2038 file I/O error when I try to tag the request for "public-read" and wouldn't mind getting some help from anyone else working on this. Thanks,

Todd
Email: toddwatson23 at gmail

Posted by: Todd at January 10, 2008 1:47 PM

Hey,

I just thought I would follow up on this, never heard anything more and am still looking but here is my work around. I decided to just give up on setting the acl in Actionscript because I kept getting the 2038 file I/O error and everything worked fine in the upload without it. I figured that I need confirmation on my server that the file was successfully uploaded to S3, so I took the route to upload with no acl tag, then send a confirmation to our php server who then sends a set acl command on the file that was uploaded. The php library works great and I have no problem getting the acl reset. Once that is confirmed by my php server, it responds back to the air app with confirmation that everything was successful. Kind of a round-a-bout way but we needed the confirmation step on our server anyway, so we added the acl there.

Anyway, there's probably a really dumb reason why the ACL isn't working on upload in ActionScript and I would love to hear if someone figures out why because I would prefer the tag is set on upload. Thanks,

Todd
Email: toddwatson23 at gmail

Posted by: Todd at February 1, 2008 12:54 PM

I think I may have an idea as to why the upload is failing with 2038.

The AS3 lib creates custom headers for S3 authentication in getURLRequest(). This works for GET and DELETE, but the headers aren't sent when the upload is attempted with PUT. I found this out by tracing the URLRequest object at the same time I was using a packet sniffer to see what Air was actually sending. The URLRequest object has the proper authentication data and date, but the wire trace shows only the following headers:

Connection: close
User-Agent: Adobe Flash Player 9
X-Flash-Version: 9,0,99,0
Accept-Types: text/*
Content-Length: 18
Host: s3.amazonaws.com:80

S3 also replies with an HTTP 403 which seems to support this.

It looks like Amazon recently added POST support, but that's just more data to track. There's also a WSDL that I've not tried binding to which may avoid the problem. Hope this is helpful.

Posted by: Matt Weagle at February 2, 2008 7:25 AM

I'm trying to use this lib in Flash CS3 Pro. I'm fairly new to ActionSCript (but not Javascript or scripting in general).

I've d/l'd the deps and checked out the source for this. I'm using the Flex 3.0 SDK.

I added the top level src dirs of all the deps to my app's classpath, but when I run it I get:

Error: No class registered for interface 'mx.resources::IResourceManager'.

from the DateFormatter...

I'll be darned if I can't figure out how to register a class for this... any hints?

Posted by: Chris F at February 28, 2008 10:52 AM

This bug on Adobe's JIRA explains your problem, Chris F:

http://bugs.adobe.com/jira/browse/SDK-12205

Posted by: Rob Jellinghaus at March 18, 2008 9:25 AM

To Chris F: Check out the bug entry for this:

http://bugs.adobe.com/jira/browse/SDK-12205

I've appended a possible workaround to that bug entry, let us know if it works!

Posted by: Rob Jellinghaus at March 18, 2008 10:19 AM

Hi Christian,
thanks for working on the library I just wanted to alert you to a bug I discovered working with buckets with special configuration.

When trying to use your library for accessing S3 buckets I discovered an error which is due to the fact that buckets created in the EU and US use different access URLs.
Using the library I S3 sends back a PermanentRedirect error (http://docs.amazonwebservices.com/AmazonS3/2006-03-01/ErrorCodeList.html) because the bucket was created with a special bucket configuration (http://docs.amazonwebservices.com/AmazonS3/2006-03-01/BucketConfiguration.html#LocationSelection), in this case it was created as an EU bucket, an error is thrown.

To work around this I added an IOErrorEvent.ERROR handler in the listObjects method of the AWSS3 class which retries the request and retries the request with the EU URL format for the bucket.

A permanent solution which should go into the library would be to use the BucketLocation (http://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTBucketLocationGET.html) request first to get the correct configuration for the bucket.

Posted by: espen at June 10, 2008 1:49 AM

I can't seem to find the code to download at

http://code.google.com/p/as3awss3lib/

there are no files to download, where can I find the library?

Posted by: steve at August 14, 2008 2:25 PM

I can't seem to find the code to download at

http://code.google.com/p/as3awss3lib/

there are no files to download, where can I find the library?

Christian says: You have to check the code out via SVN. There are no zip file downloads available.

Posted by: joeoe at September 21, 2008 9:45 PM

any idea where the flex app or anything has gone, has it been updated for the release version. I have svn ed the code from google, but would like some pointers on the flex app,

thanks again

Posted by: mpeeba3 at February 11, 2009 11:54 AM




Remember Me?

(you may use HTML tags for style)

Copyright © 2009 Adobe Systems Incorporated. All rights reserved.
Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy (updated 07-14-2009).