Drupal provides both public and private file systems. S3 File System (Amazon S3) provides an additional file system to the Drupal site. S3FS module is used to store files in Amazon S3 (Simple Storage Service) or any other S3-compatible storage service. You can configure your Drupal site to use S3 File System as default, or use it only for individual fields.
Amazon S3 vs Amazon CloudFront
Amazon S3 is designed for large-capacity and low-cost file storage in the specific geographical region.The storage and bandwidth costs are quite low. Compared to this, Amazon CloudFront is a Content Delivery Network (CDN) which caches web data at edge locations as close as possible to the user.
- You don’t have to purchase an additional hardware as your space requirements grow.
- You receive secure and managed hosting at very low costs.
- Your server will have an offsite backup in case something goes wrong.
- Ample amount of data can be stored in a bucket.
1. Amazon S3 bucket
2. Composer- Composer installs S3 module dependencies such as AWS SDK
3. S3FS Module: Drupal module is required for getting connected to Amazon S3 bucket.
1. On the terminal, go to the project root folder and execute the following commands:
drush dl s3fs
2. Run the below composer command
composer config repositories.drupal composer https://packages.drupal.org/8 && composer require drupal/s3fs
After running this command, you will get the following screen:
3. drush en s3fs
4. Goto /admin/config/media/file-system and set the “Default download method” checkbox to “Amazon Simple Storage Service”.
5: Add the type File and Image fields in any content type and set the “Upload destination” to “S3 File System” in the “Field Settings” tab.
6: Configure your S3FS module settings for S3 File System. Add your S3 bucket name at /admin/config/media/s3fs. You can Enter your AWS credentials.
A- Amazon Web Services Access Key
B- Amazon Web Services Secret Key
C- S3 Bucket Name
After installation, upload your first file by using node creation form. If you are not able to see the uploaded file, it is because your bucket is not yet public. Please go to your bucket, select the s3fs-public folder and then further go to actions and change the status to Public.
ADDITIONAL FOLDER SETTINGS
If your files exist in another folder inside the root of S3 Bucket, you can enter the folder name in “Public Folder” and “Private Folder” text fields in additional folder setting.
Hope this article gave you a good understanding of S3 File System (Amazon S3) requirements and installation.