The AmazonS3 module allows the local file system to be replaced with S3. Uploads are saved into the Drupal file table using D7's file/stream wrapper system.
You can also use it with other S3 compatible cloud storage services such as Google Cloud Storage.
You can switch it on as the default file system scheme, or individually for file and image fields.
Most module configuration is handled at admin/config/media/amazons3
. At a
minimum, S3 credentials and a default bucket will need to be configured. It's
best to configure these settings in $conf
variables in settings.php
.
To use signed CloudFront URLs, the CloudFront private key and ID are needed.
The private key is a .pem
file, and should be stored outside of your document
root. Set $conf['amazons3_cloudfront_private_key']
to the path of the private
key and $conf['amazons3_cloudfront_keypair_id']
to the key ID in settings.php
to enable this feature.
While Drupal core and contrib have basic support for remote stream wrappers, most modules have issues where they hard code URIs or specific file systems. All of these patches except for the Imagemagick patch add simple alter hooks, so they should be unlikely to cause problems.
file.inc
needs to be
patched to add an alter hook.To use IMCE to manage files in S3:
file.inc
needs to be
patched to add an alter hook.
This is the same patch as the above patch for Media module.You can modify the generated URL and it's properties, this is very useful for setting Cache-Control and Expires headers (as long as you aren't using CloudFront).
You can also alter the metadata for each object saved to S3 with hook_amazons3_save_headers(). This is very useful for forcing the content-disposition header to force download files if they're being delivered through CloudFront presigned URLs.
See amazons3.api.php
The included unit tests do not have any dependency on a Drupal installation. By using PHPUnit, you can integrate test results into your IDE of choice.
composer install
in the module directory.vendor/bin/phpunit tests
.In PHPStorm, it's easiest to configure PHPUnit to use the autoloader generated in vendor/autoload.php. It's also good to mark the vendor directory as excluded, if you already have a vendor directory indexed from composer_manager.