paperclip save to disk and s3

I have a standard Paperclip setup that saves a file to my disk. In
addition I would also like the file saved to my amazon s3 bucket.


after_save :copy_to_s3

  def copy_to_s3
   has_attached_file :photo,
   :storage => :s3,
   :s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
   :styles => {
   :thumb => "100x100#",
   :small => "750x750>" }


This is giving the error: undefined method `has_attached_file'

Because it's in another scope of object
And it's nothing give to u, it's one define some methods

U can open paperclip source and find out how call upload to s3, or u can use aws-s3 gem, which simple, s3 is http based storage, simple http query, and all a done ))

Scratch the idea then.

So I found this gem called db2s3 which is used to backup the database
with a simple rake command. I having trouble modifying it accordingly.

require 'activesupport'
require 'aws/s3'
require 'tempfile'

  class Config

  def initialize

  def full_backup

    file_name = "system-#{"%Y%m%d%H%M")}.gz", open(backup_directory.path)), file_name)



  def backup_directory
     backup_file ="dump")

     cmd = "cp -r #{RAILS_ROOT}/public/system/ bucket"
     cmd += " | gzip > #{backup_file.path}"


  def store
    @store ||=

  def most_recent_dump_file_name

  def run(command)
    result = system(command)
    raise("error, process exited with status #{$?.exitstatus}") unless

  def db_credentials
    ActiveRecord::Base.connection.instance_eval { @config } # Dodgy!

  class S3Store
    def initialize
      @connected = false

    def ensure_connected
      return if @connected
:secret_access_key).merge(:use_ssl => true))
      @connected = true

    def store(file_name, file)
      ensure_connected, file, bucket)

    def fetch(file_name)
      AWS::S3::S3Object.find(file_name, bucket)

      file ="dump")
      open(file.path, 'w') do |f|, bucket) do |chunk|
          f.write chunk

    def list
      AWS::S3::Bucket.find(bucket).objects.collect {|x| x.path }

    def delete(file_name)
      if object = AWS::S3::S3Object.find(file_name, bucket)


    def bucket


In the backup_directory method, I can't figure out how to get it to copy
the system directory into my s3 bucket.