Level 2
The trick is to create an AWS client and then use putObject to store the file.
http://docs.aws.amazon.com/aws-sdk-php/v3/api/api-s3-2006-03-01.html#putobject
$filename=$request->file('upload')->getFilename();
$file_ext=$request->file('upload')->clientExtension();
$path="files/".$this->user->customer->id.'/'.$filename.'_'.str_random(15).'.'. $file_ext;
$client = new \Aws\S3\S3Client([
'version' => 'latest',
'region' => env('AWS_REGION'),
]);
$result = $client->putObject([
'ACL' => 'private',
'Bucket' => env('AWS_BUCKET'), // REQUIRED
'Key' => $path, // REQUIRED
'ServerSideEncryption' => 'AES256',
'SourceFile'=> $request->file('upload'),
'StorageClass' => 'STANDARD',
]);
2 likes