Dha*_*eda 2 php amazon-s3 laravel
我想以编程方式从我的存储桶中删除文件,但它没有发生
我有下面的代码
$s3 = \Storage::disk('s3');
$existingImagePath = $studentPortfolios[$i]->portfolio_link; // this returns the path of the file stored in the db
$s3->delete($existingImagePath);
Run Code Online (Sandbox Code Playgroud)
但这并不是从存储桶中删除文件
当我从本地设置运行它时,我必须暂时为每个人向存储桶写入对象权限。
请注意:- 我可以上传文件,但删除不起作用
对此的任何建议都会非常有帮助。
小智 5
就像从磁盘删除文件一样。检查 Laravel 文档:https://laravel.com/docs/5.6/filesystem#deleting-files
$imageName = $studentPortfolios[$i]->portfolio_link; // this returns the file name stored in the DB
\Storage::disk('s3')->delete('s3_folder_path/'. $imageName);
Run Code Online (Sandbox Code Playgroud)
确保文件具有删除权限。如果未从 s3 授予权限,请选择文件或目录,然后从 s3 中的操作中选择“公开”选项。
| 归档时间: |
|
| 查看次数: |
19551 次 |
| 最近记录: |