Uploads

Document Navigation

Uploads

Introduction

Cmfive supports two different types of file adapters for uploads to best suit your needs.

  • The Local Adapter is enabled by default and requires no further setup.
  • The S3 Adapter provides a more available and reliable solution.

S3 Adapter

  1. Add the following entries into the config.php file in the root directory of your Cmfive project.
     Config::set("file.adapters.local.active", false);
    
     Config::set("file.adapters.s3", [
         "active"      => true,
         "region"      => "S3_BUCKET_REGION",
         "version"     => "2006-03-01",
         "credentials" => [
             "key"    => "IAM_KEY",
             "secret" => "IAM_SECRET",
         ],
         "bucket"      => "S3_BUCKET_NAME",
         "options"     => [
             "directory" => "uploads",
             "create"    => true
         ],
     ]);
    
  2. If you’re developing on Cmfive locally, also add the following. Note, when system.environment is set to production AWS IAM Roles must be used to authenticate with AWS as this is best practice for security.
     Config::set("file.adapters.s3.credentials", [
         "key"    => "IAM_KEY",
         "secret" => "IAM_SECRET",
     ]);
    
     Config::set("system.environment", "development");
    
  3. Replace S3_BUCKET_REGION, IAM_KEY, IAM_SECRET and S3_BUCKET_NAME with their respective values as well as IAM_KEY and IAM_SECRET if system.environment is set to development.

  4. Make sure to clear your config cache to apply your changes.

  5. If you have any files stored locally from prior to using the S3 Adapter you can run file transfer tool in the admin module from within Cmfive to move them to S3. File Transfer Tool