Setting up Amazon S3

Andy

Administrator
Staff member
Follow these instructions to create an Amazon S3 account:

https://xenforo.com/community/resou...or-amazon-s3-for-file-storage-in-xf-2-x.6805/

1. Install the AFAws add-on. You should see this in your installed add-on list:

1654078645639.jpg


2. Edit the XenForo config.php file with the example code shown below. Be sure to update the code below with your correct path, credentials, region and Amazon S3 bucket name.

PHP:
$config['codeCachePath'] = '/home/username/public_html/forums/internal_data/code_cache';
$config['tempDataPath'] = '/home/username/public_html/forums/internal_data/temp';

$s3 = function()
{
   return new \Aws\S3\S3Client([
      'credentials' => [
         'key' => '123',
         'secret' => 'ABC'
      ],
      'region' => 'us-east-2',
      'version' => 'latest',
      'endpoint' => 'https://s3.us-east-2.amazonaws.com'
   ]);
};

$config['fsAdapters']['data'] = function() use($s3)
{
   return new \League\Flysystem\AwsS3v3\AwsS3Adapter($s3(), 'bucket_name', 'data');
};

$config['externalDataUrl'] = function($externalPath, $canonical)
{
   return 'https://bucket_name.s3.us-east-2.amazonaws.com/data/' . $externalPath;
};

$config['fsAdapters']['internal-data'] = function() use($s3)
{
   return new \League\Flysystem\AwsS3v3\AwsS3Adapter($s3(), 'bucket_name', 'internal_data');
};

$config['internalDataUrl'] = function($internalPath, $canonical)
{
   return 'https://bucket_name.s3.us-east-2.amazonaws.com/internal_data/' . $internalPath;
};
 
Top