简体   繁体   English

Rails Active Storage,从 S3 存储桶中删除文件

[英]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.

相关问题 Rails Active Storage - 如何将本地文件迁移到 s3 存储桶 - Rails Active Storage - How to migrate local files to s3 bucket 无法使用 Rails Active Storage 从 S3 检索文件 - Can't retrieve file from S3 with Rails Active Storage Rails 6 Active storage sidekiq 文件在 S3 上上传背景图片 - Rails 6 Active storage sidekiq file upload background image on S3 Rails Active Storage &amp; AWS S3:如何通过seeds.rb 将图像附加到模型,然后将其存储在S3 私有存储桶中? - Rails Active Storage & AWS S3 : How to attach image to model through seeds.rb and then store it in S3 private bucket? 有什么办法可以从s3 bucket Rails中读取.doc文件 - Is there any way to read a .doc file from s3 bucket Rails 使用Ruby SDK从S3存储桶中删除 - Delete from S3 bucket with Ruby SDK 如何使用 Active Storage Rails 上传到带有 AES256 加密(服务器端加密)的 AWS S3 存储桶? - How to upload to a AWS S3 bucket with AES256 encryption(Server side encryption) using Active Storage Rails? 如何使用rails的Active Storage将图像上传到S3 <canvas /> 以铁轨形式? - How can I upload an image to S3 with rails' Active Storage from a <canvas /> in a rails form? 我无法使用Rails从s3删除文件 - I am unable to delete file from the s3 using rails 如何在 Ruby on Rails Active Storage 上为 S3 设置传输加速 - How to Setup Transfer Acceleration for S3 on Ruby on Rails Active Storage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM