I’m trying to implement file upload to amazon s3. I’m getting following error
Cannot redeclare GuzzleHttp\uri_template() (previously declared in /var/www/html/appname/vendor/guzzlehttp/guzzle/src/functions.php:17) File /var/www/html/appname/vendor/aws/GuzzleHttp/functions.php
In upload controller, using below code to upload
require_once("../vendor/aws/aws-autoloader.php");
use Aws\S3\S3Client;
public function upload(){
$s3 = S3Client::factory(array( 'version' =>
'latest', 'region' => 'ap-south-1', 'credentials' => array(
'key' => 'key',
'secret' => 'secret' ) ));
if ($this->request->is('post'))
{
if(!empty($this->request->data['file']['name']))
{
$fileName = $this->request->data['file']['name'];
$s3->putObject([
'Bucket' => backetname,
'Key' => $fileName,
'SourceFile' => $this->request->data['file']['tmp_name'],
'ContentType' => 'image/jpeg',
'ACL' => 'public-read',
'StorageClass' => 'REDUCED_REDUNDANCY'
]);
}
}
}