Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete files in amazon S3 from ruby

I have made a ruby on rails application with amw S3.

I can upload the photo, but I try to delete the photo, even though the photo reference is deleted in database, the photo is still in S3.

How do I actually delete files from S3?

like image 462
justicepenny Avatar asked Sep 02 '12 10:09

justicepenny


Video Answer


1 Answers

Your question isn't correctly specified. If you could provide more information, it would be great. But here are some options how to handle files on Amazon S3.

According to this documentation you can use method delete(see the implementation) from the Ruby Library for Amazon's Simple Storage Service's (S3) REST API.

So the should look like this:

AWS::S3::S3Object.delete('goodbye.txt', 'my-new-bucket')

Very helpful could be also this question.

Anyway I highly recommend you to use Paperclip or Carrierwave when uploading files to Amazon S3. Some helpful articles:

  1. Configure Carrierwave for Amazon S3 Storage and Heroku
  2. RailsCast #383 Uploading to Amazon S3
like image 106
Tom Hert Avatar answered Oct 15 '22 20:10

Tom Hert