[英]Rails Active Storage, delete file from S3 bucket
I am using Active Storage to upload images to S3 bucket.我正在使用 Active Storage 将图像上传到 S3 存储桶。 Everything is working fine but when I am deleting image file from console then file is not deleted from S3 bucket.
一切正常,但是当我从控制台删除图像文件时,文件不会从 S3 存储桶中删除。 Rails documentation says that using
purge
will delete file from S3 bucket as well. Rails 文档说,使用
purge
也会从 S3 存储桶中删除文件。 But in my case I can still see the file in S3 bucket.但就我而言,我仍然可以在 S3 存储桶中看到该文件。 Below are the commands which I am using to delete file from console.
以下是我用来从控制台删除文件的命令。
company = Company.first
company.logo.purge # this is deleting the file in console but not deleting file in S3 bucket.
when I check the log from rails server then its saying deleting from Disk Storage rather than S3.当我从 Rails 服务器检查日志时,它说从磁盘存储而不是 S3 中删除。 Below is my log.
下面是我的日志。
Disk Storage (0.4ms) Deleted file from key: 1x29cv8bkur97n3fosu9qwfx8316
Disk Storage (0.1ms) Deleted files by key prefix: variants/1x29cv8bkur97n3fosu9qwfx8316/
So how can I delete the file from S3 bucket using rails console.那么如何使用 rails 控制台从 S3 存储桶中删除文件。
UPDATE: I don't know what was the problem but restarting my rails console fix the problem.更新:我不知道问题出在哪里,但重新启动我的 rails 控制台可以解决问题。
I don't know what was the problem but restarting my rails console fix the problem.我不知道是什么问题,但重新启动我的 rails 控制台可以解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.