2017-10-04 132 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數據不是文件對象。

相關問題