GithubHelp home page GithubHelp logo

qwertmax / drupal_amazons3 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from justafish/drupal_amazons3

0.0 2.0 0.0 303 KB

The AmazonS3 Drupal module allows the local file system to be replaced with S3. Uploads are saved into the drupal file table using D7's new file/stream wrapper system.

Home Page: http://drupal.org/project/amazons3

PHP 100.00%

drupal_amazons3's Introduction

AmazonS3

Build Status Coverage Status

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.

Requirements

Configuration

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.

Installation

  • Review the patch notes below. Nearly all sites will need the very first patch against Drupal's image module.
  • Download and install Composer Manager and AmazonS3 Drupal modules.
  • Enable the AmazonS3 module. It's easiest to use drush so it will automatically download the AWS SDK.
  • Configure the AmazonS3 credentials and other settings at /admin/config/media/amazon

Patches for full functionality

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.

Image styles

Media module, file entities, and plupload

IMCE

To use IMCE to manage files in S3:

Usage

  • Change individual fields to upload to S3 in the field settings
  • Use AmazonS3 instead of the public file system (although there are a few issues due to core hardcoding the use of public:// in a few places e.g. aggregated CSS and JS). Go to /admin/config/media/file-system and set the default download method to Amazon.
  • When using Features to export field definitions, the Upload destination is included. If you want to override this (for example, in a multi-environment workflow), use the 'amazons3_file_uri_scheme_override' variable. See amazons3_field_default_field_bases_alter() for documentation.

API

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

Running PHPUnit tests

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.

  • Run composer install in the module directory.
  • Run 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.

Related Modules

drupal_amazons3's People

Contributors

deviantintegral avatar justafish avatar qwertmax avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.