Rafael Oliveira
Rafael Oliveira

Reputation: 2923

Carrierwave - Delete file from Amazon S3 but keep the record on db

I see we can use object.file.remove! or object.remove_file! to remove files from S3, but object still holds the .file.

I want to set object.file to nil or empty, because I want to remove the file from S3 but still want to keep the record on my database (for statistics purposes).

Upvotes: 0

Views: 1086

Answers (1)

kobaltz
kobaltz

Reputation: 7070

You could add another field in your File table called expired. In the method that deletes the file from S3, use the update_attribute to change the expired field. If expired equals true then do not allow the "file" to be downloaded.

Document.update_attribute(:expired, true)   

Upvotes: 1

Related Questions