Trying to upload a pdf to aws s3 bucket, but its showing me below error.
Error
Argument 2 passed to Aws\AwsClient::getCommand() must be of the type array, string given
called in C:\xampp\htdocs\property\vendor\aws\aws-sdk-php\src\AwsClientTrait.php on line 77
and defined in C:\xampp\htdocs\property\vendor\aws\aws-sdk-php\src\AwsClient.php on line 209
Below is my code
1) config.php
return[
'S3'=>[
'key' =>key,
'secret' =>secret_key,
'bucket' =>bucket_name
]
];
2) start.php
require '../vendor/autoload.php';
use Aws\S3\S3Client;
$config = require ('config.php');
//create s3 instance
$S3 = S3Client::factory([
'version'=>'latest',
'region' => 'us-east-1',
'credentials' => array(
'key' => KEY,
'secret' => SECRET_KEY
)
]);
3) upload part
require '../fpdf/fpdf.php';
require 'start.php';
use Aws\Exception\AwsException;
$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',14);
$txt = "Legal Document of Mr.pradeep";
$pdf->Cell(180,0,$txt,0,1,'C');
$pdf->Line(5,20,200,20);
$pdf->SetFont('Arial','',12);
$content = "This is the AGREEMENT to purchase made by pradeep from XYZ on day XX/XX/XXXX,";
$pdf->Cell(5,30,$content,0,0,'');
$content = "is located at bangalore and his dob is XX/XX/XXXX will be owner of the plot";
$pdf->Cell(0,45,$content,0,0,'');
$docname = "legaldoc.pdf";
$filepath = "../file/{$docname}";
$pdf->Output($filepath,'F');
try{
$S3->putObject([
'Bucket' => $config['S3']['bucket'],
'Key' => "folder",
'Body' => fopen($filepath,'rb'),
'ACL' => 'public-read'
]);
} catch (S3Exception $e) {
echo $e->getMessage() . "\n";
}