Amazon S3 Grails Plugin
This plugin is written for the Groovy on Grails web application framework, and intends to make it relatively easy to host files such as images, Flash, movies and audio all on the Amazon Web Services Simple Storage Service (S3). The goals of this plugin are as follows:
- Host and manage file assets on Amazon S3 for storage and performance advantages
- Provide easy mechanisms to reference S3-hosted assets in Grails applications
- Make most efficient and cost-effective use of S3 hosting resources
To achieve these goals, the plugin provides services to manage static media assets for a Grails application. For the first revision of the plugin, the focus is on managing user uploaded static content. Later revisions will place a focus on providing tools to migrate existing static content in a site (such as items under the /images folder) into S3.
This plugin uses the excellent JetS3t Toolkit (http://jets3t.s3.amazonaws.com/index.html) to communicate with the Amazon S3 service.
Author: Cantina Consulting
Features
The initial revision of the plugin focuses on managing user uploaded content. As such it provides these features:
- Grails Service artifact that provides synchronous and asynchronous (background) upload of assets to S3
- Utilizes the jets3t Java S3 library for efficient upload to S3
- Grails tag library "<s3:createLinkTo>" which provides the ability to create links to a managed S3 Asset, whether it is local (before background sync) or already uploaded to S3
- Small MVC application included to manage user uploaded S3 assets to serve as an administrative utility as well as a reference application that makes use of the Grails Service (S3AssetService)
Roadmap
To achieve the goals mentioned above, we are also planning several more features to be released in the near future.
- Provide tools to import existing static media assets into plugin for hosting on S3
- Support custom naming schemes for S3 asset URLs
- Integration with other media plugins (perhaps ImageTools) for thumbnail generation and video frame grabbing
- Support for custom bucket schemes
- Security integration with Acegi or JSecurity plugins to manage access control lists on S3 assets
- Support both REST and SOAP protocols (currently only uses REST)
- Reporting on S3 usage
Requirements
This plugin was built using the Groovy on Grails version 1.0 RC1. We will make every effort to update the plugin to the final 1.0 release when it is out. The plugin has also been tested against Groovy 1.0 and the latest release candidate for Groovy 1.1. The plugin comes bundled with jets3t-0.5.0.jar which it uses for communication with S3.
Installation
- Download the latest version of the plugin using the link below:
grails-amazon-s3-0.1.zip - The plugin depends on the Grails Quartz plugin version 0.2 or higher. To install that go to your Grails application and type:grails install-plugin quartz 0.2
- Install the plugin:grails install-plugin <path to your downloaded plugin zip>
This download location upon review and acceptance from the Grails community we will move the plugin to the official Grails plugin repository located at http://svn.codehaus.org/grails-plugins/.
Usage
The plugin makes use of whatever datasource the application has defined for database access, as all assets entered into the system are managed using a domain class called S3Asset.
The plugin also requires specific configuration information to be able to connect to the Amazon S3 service. This configuration should appear in your application's Config.groovy file. An example of this configuration is given below:
aws {
domain="s3.amazonaws.com"
accessKey="0123456789ABCDEFG"
secretKey="0123456789ABCDEFGHIJKLMNOPQRS"
bucketName="files"
localAssetPath="assets"
}
A description of each of these configuration elements is given below:
| domain | The domain from which Amazon S3 assets will be served. This by default will be s3.amazonaws.com, unless you've created a DNS CNAME to provide a different domain for your Amazon S3 assets |
| accessKey | Your public API access key for AWS |
| secretKey | Your private API access key for AWS |
| bucketName | The name of the bucket where all files should reside(Note: later versions of the plugin will support multiple buckets) |
| localAssetPath | A directory under your Grails web application root folder (web-app) where media assets will be uploaded and served by the Grails application until the assets are transferred to S3 |
Licensing
This plugin is open source and is licensed under the Apache License, version 2.0 (http://www.apache.org/licenses/LICENSE-2.0).
Feedback
The Grails community has been an amazing resource during our own development with the Groovy and Grails framework and we welcome (and hope for) feedback from the community on the design and purpose of the plugin as well as possible usability and performance enhancements. We're constantly checking the Grails Mailing Lists for comments and feedback on the plugin. You can also reach us on the Grails User and Dev mailing lists or by emailing us at info@cantinaconsulting.com.