This module works in conjunction with the amazons3 module to provide direct to S3 uploading from your browser. Bypassing the Drupal file system and storing all files in S3 only.

When using this method to upload files to S3 files are uploaded directly from the user's browser to S3 and not stored in the local file system. This can be nice in that you don't have to upload files to Drupal first and then have Drupal transfer them to S3 for you. The module then stores a managed file record in Drupal for the new file and the file is then treated just like any file that was uploaded via the normal means.

The module provides a new field widget for file fields.

The module provides a new #type = amazons3_cors_upload element that can be used by others and functions similar to the #type = managed_file element. Display a file upload widget and when the form is submitted your submit handler will be given the FID of the new file.

Both the field widget and FAPI element support display of upload progress via XHR upload progress in browser's that support cool things like that.

Setup

In order to work with S3 you'll need to configure a CORS (Cross Origin Resource Sharing) policy for your bucket. Create a policy be navigating to the permissions screen for your S3 bucket and clicking the "Edit CORS Configuration" button and creating a policy suitable for your use case. Something like the following should do the trick and allow only uploads from http://example.com

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <CORSRule>
        <AllowedOrigin>http://example.com</AllowedOrigin>
        <AllowedMethod>POST</AllowedMethod>
        <MaxAgeSeconds>3000</MaxAgeSeconds>
        <AllowedHeader>*</AllowedHeader>
    </CORSRule>
</CORSConfiguration>

Learn more about using CORS with AWS and about configuring a bucket with CORS support.

You will also need to enter your AWS keys into the configuration screen for AWSSDK or add them to yur settings.php file:

<?php
$conf
['amazons3_bucket'] = '';
$conf['aws_key'] = '';
$conf['aws_secret'] = '';
?>

Requirements

An Amazon Web Services account.

AmazonS3 module
jQuery Update module

Magic.

Current Known Bugs / Limitations / other things.

This module has not been tested w/ multiple value file fields and will likely fail in a ball of fire. You've been warned.

This is still somewhat experimental and has not been used in a production environment. Though in my testing thus far it's accomplishing what I need it to including uploads of 1Gb + files.

Project Information

Downloads