S3 with Railo

Some of you may know that there is a Amazon S3 CFC you can download from RiaForge. Railo has an own way of handling Amazon S3 resources.

When you want to use Amazon S3 it can become quite challenging to use the service for storing and reading data with CFML. Here the amazon S3 CFC helps a little.
Since Railo 2.0 introduced resources (virtual file systems) and everything file based in Railo is based on these resources, we have implemented a new resource called S3. This resource can be used as any other resource as well. So if you have an accessKeyID and a secretAccessKey, you can use it quite easy like follows:


<cffile action="copy" source="s3://[accessKeyID]:[secretAccessKey]@s3.amazonaws.com/susi.txt"
destination="c:\susi.txt">


Now, if you define a mapping that points to a S3 resource like follows:

MappingName:
/myS3Storage
Resource path
s3://[accessKeyID]:[secretAccessKey]@s3.amazonaws.com/

you can use it in your code like this:

<cfinclude template="/myS3Resource/susi.cfm"> <!--- or --->
<cfif fileExists("/myS3Resource/susi.cfm")>
...
</cfif>
<cfdirectory dir="/myS3Resource" action="list" name="s3Files>
<cfdump eval="
s3Files">

So it is very easy to store your video files you convert with to the Amazon S3.

Updated: December 15th, 2009

Railo's Amazon S3 extension is a paid extension. If you need information about availability / cost, please Contact us.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Andrew Grosset's Gravatar Works great! dont forget to remove the "[ ]" around your access keys,

Andrew.
# Posted By Andrew Grosset | 05.01.09 21:09
Andrew Grosset's Gravatar having trouble setting acl permissions in amazon s3, although the acl below is set to "public-read" it is in fact being set to "private" ie the acl setting is being ignored. I am using "railo-3.0.1.000-railo-express-6.1.0-with-jre-windows"

<cffile
action = "copy"
source = "C:\mystuff\pics\balloons3d.jpg"
destination = "/myS3Storage/andrew/files/balloons3d.jpg"
acl = "public-read"
>

Andrew.
# Posted By Andrew Grosset | 12.01.09 06:37
Jeff's Gravatar Having trouble trying to connect to AWS. I put in my key and secrety key just like the blog post described, but the Railo admin won't save it. Just highlights the resource in red.

However, I am able to connect with a different freeware utility using the same credentials/
# Posted By Jeff | 23.04.09 06:27
Gert Franz's Gravatar Jeff,

are you using Railo 3.0 or 3.1? This is an extension now in Railo 3.1. In addition you might need to add a certain JAR file and restart the engine.
Have a look at Mark's latest blog posts: http://www.markdrew.co.uk

Gert
# Posted By Gert Franz | 23.04.09 08:47
Dave Anderson's Gravatar I'm new to Railo and S3...where do 'buckets' come into play in all this? Should there not be a bucket name in that path? Are they treated as directories, and thus can be created with cfdirectory if there's an s3 mapping?
# Posted By Dave Anderson | 23.05.09 06:04
Gert Franz's Gravatar @dave:

The buckets are just like directoriy names appended at the end of the s3resource. Sou your definition can look like this:

s3://[accessKeyID]:[secretAccessKey]@s3.amazonaws.com/[bucketname]

Gert
# Posted By Gert Franz | 29.05.09 10:00
BlogCFC was created by Raymond Camden. This blog is running version 5.9.1.002. Contact Blog Owner