2017-10-04 134 views
1

我正在使用laravel api应用程序,并且必须将base64编码图像上传到AWS S3存储桶。如何在Laravel 5.5的S3存储桶中上传base64映像

我可以直接上传通过

$this->request->imageInput->store('public');//in local server 
Storage::disk('s3')->put('FILENAME', file_get_contents('imageInput'));//in S3 server 

图像如何上传到AWS S3存储编码的图像中的Base64并同时获得在这里我们可以得到图像信息的反应如何?

回答

-1

你可能需要使用该图片解码:

$tmp = base64_decode($base64); 

并将其存储后在Amazon S3上

+0

谢谢...之后,我们将如何做到这一点。 – user3419778

+1

这真的是一个答案吗? @Vincent我真的不明白你的意图与这种答案,你甚至没有回答这个问题,也没有提出一个解决方案。 –

1
list($baseType, $image) = explode(';', $base64); 
list(, $image) = explode(',', $image); 
$image = base64_decode($image); 

$imageName = rand(111111111, 999999999) . '.png'; 
$p = Storage::disk('s3')->put('filepath/' . $imageName, $image, 'public'); // old : $file 

关键的一点是,你需要给具体的文件名。

适配器无法获得base64数据的真实路径。我猜这是因为base64数据不是文件对象。

相关问题