waynehoover/s3_direct_upload — pull request #23 by ericboehs (2012-12-10 22:55:16+00:00)
Title: Rake task to clean old uploads

From the modified README:

## Cleaning old uploads on S3
You may be processing the files upon upload and reuploading them to another
bucket or directory. If so you can remove the originali files by running a
rake task.

First, add the fog gem to your `Gemfile` and run `bundle`:
```ruby
require 'fog'
```

Then, run the rake task to delete uploads older than 2 days:
```
$ rake s3_direct_upload:clean_remote_uploads
Deleted file with key: "uploads/20121210T2139Z_03846cb0329b6a8eba481ec689135701/06 - PCR_RYA014-25.jpg"
Deleted file with key: "uploads/20121210T2139Z_03846cb0329b6a8eba481ec689135701/05 - PCR_RYA014-24.jpg"
$
```

Optionally customize the prefix used for cleaning (default is `uploads/#{2.days.ago.strftime('%Y%m%d')}`):
**config/initalizers/s3_direct_upload.rb**
```ruby
S3DirectUpload.config do |c|
# ...
c.prefix_to_clean = "my_path/#{1.week.ago.strftime('%y%m%d')}"
end
```