Welcome Guest, Not a member yet? Register   Sign In
Need help connecting to Amazon S3 storage
#2

The official AWS SDK for PHP, installed via Composer, works fine with CI 4.

It can be registered and used with CI4 services:

Code:
/* In Config/Services.php: */

public static function aws($getShared = true)
{
if ($getShared) {
return static::getSharedInstance('aws');
}

$config = config('AWS');

$credentials = new \Aws\Credentials\Credentials($config->accessKey, $config->secretKey);

$sdk = new \Aws\Sdk([
'credentials' => $credentials,
'region' => $config->region,
]);

return $sdk;
}

Code:
<?php

/* Config/AWS.php */

namespace Config;

use CodeIgniter\Config\BaseConfig;

class AWS extends BaseConfig
{

public $region = 'eu-west-2';

public $accessKey = '';
public $secretKey = '';

public $inputS3bucket = '';
public $outputS3bucket = '';

}

Code:
# in your .env
aws.accessKey = ABC123...
aws.secretKey = xyz789...
Reply


Messages In This Thread
RE: Need help connecting to Amazon S3 storage - by craig - 06-21-2021, 03:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB