Mat*_*att 10 php amazon-s3 amazon-web-services
我的应用程序将图像上传到s3.我使用前端渲染来获取图像的颜色,但是因为上传到s3会降低质量(jpeg'ish),所以我会得到更多颜色.
$s3 = \Storage::disk('s3');
$s3->put('/images/file.jpg', '/images/file.jpg', 'public');
Run Code Online (Sandbox Code Playgroud)
有没有办法防止这种质量损失?我注意到如果我使用aws控制台网站直接上传文件,质量保持不变,这是理想的.
谢谢!
在控制器动作中
\n\npublic function uploadFileToS3(Request $request)\n{\n $image = $request->file(\'image\');\n} \nRun Code Online (Sandbox Code Playgroud)\n\n接下来,我们需要为上传的文件分配一个文件名。您可以将其保留为原始文件名,但在大多数情况下,您需要更改它以保持一致。让\xe2\x80\x99s 将其更改为时间戳,并附加文件扩展名。
\n\n$imageFileName = time() . \'.\' . $image->getClientOriginalExtension();\nRun Code Online (Sandbox Code Playgroud)\n\n现在获取图片内容如下
\n\n$s3 = \\Storage::disk(\'s3\');\n$filePath = \'/images/file.jpg\' . $imageFileName;\n$s3->put($filePath, file_get_contents($image), \'public\');\nRun Code Online (Sandbox Code Playgroud)\n\n欲了解更多信息,您可以参考此
\n| 归档时间: |
|
| 查看次数: |
537 次 |
| 最近记录: |