I'm trying to upload a photo in vuejs and get it in laravel to send to s3 from aws.
When I upload the photo through Insomnia it uploads correctly, but when I upload it through vuejs, it returns empty.
const ob = new FormData();
ob.append("picture", this.file);
const res = await this.$http.post('/members', ob, {
headers:
{
'Content-Type': 'multipart/form-data'
}
});
public function getUrlS3($foto){
$s3Client = new S3Client([
'region' => 'us-east-1',
'version' => '2006-03-01',
]);
$result = $s3Client->putObject([
'Bucket' => 'bucket-name',
'Key' => 'file' . '.png',
'ACL' => 'public-read',
'SourceFile' => $foto, 'r'
]);
return $result;
}
$aws = new S3Controller();
$file = $request->file('picture');
$rt = $aws->getUrlS3($file);
Content-Disposition: form-data; name="picture"; filename="chiru.jpeg"
Content-Type: image/jpeg