Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6811903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:23:07+00:00 2026-05-26T20:23:07+00:00

I am using Paperclip (w/ Amazon s3) on Rails 3. I want to attach

  • 0

I am using Paperclip (w/ Amazon s3) on Rails 3. I want to attach a new file to my model without replacing the old file. I don’t want the old file to be accessible, I only want to have it there on s3 as a back up.
Do you know if there is a way of telling paperclip to take care of it, itself?

in post.rb I have:

has_attached_file :sound,
        :storage => :s3,
        :s3_credentials => "....",
        :styles => {:mp3 => {:format => :mp3}},
        :processors => [:sound_processor],
        :s3_host_alias => '....',
        :bucket => '....',
        :path => ":attachment/:id/:style/out.:extension",
        :url => ":s3_alias_url"

and the processor is as follows:

class Paperclip::SoundProcessor < Paperclip::Processor

  def initialize file, options = {}, attachment = nil
    super

    @format = options[:format] || "mp3"
    @current_format = File.extname(@file.path)
    @basename = File.basename(@file.path, @current_format)
  end

  def make
    src = @file
    dst = Tempfile.new([@basename,".#{@format}"])
    dst.binmode

    cmd = "ffmpeg -y -ab 128k -t 600 -i #{File.expand_path(src.path)} #{File.expand_path(dst.path)}"
    Paperclip.log(cmd)
    out = `#{cmd}`
    raise Paperclip::PaperclipError, "processor does not accept the given audio file" unless $?.exitstatus == 0

    dst
  end

end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:23:07+00:00Added an answer on May 26, 2026 at 8:23 pm

    Here’s what I do. I timestamp the filename before saving it (to prevent another file with the same name overwriting the original), and force paperclip to never delete anything.

    before_create :timestamp_filename
    
    def timestamp_filename
      fname = Time.now.to_s(:db).gsub(/[^0-9]/,'') + '_' + sound_file_name
      sound.instance_write(:file_name, fname)
    end
    
    # override paperclip's destroy files
    # method to always keep them around
    def destroy_attached_files
      true
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Paperclip with a Ruby on Rails to attach assets to a model,
I am using Paperclip (w/ Amazon s3) on Rails 3. I want to delete
I have a model that is using Paperclip to manage the file. After I
I have just set up file uploads to Amazon S3 using Rails 3 and
I'm using Paperclip 2.3.5 within a Rails app to store PDF documents on Amazon
How can I restrict Paperclip to only accept images? I'm using Amazon S3 for
So I've followed the instructions here: http://doganberktas.com/2010/09/14/amazon-s3-and-paperclip-rails-3/ In my profile model I have: attr_accessor
I am using paperclip and rails. I followed this tutorial: Multiple File Uploads with
I'm using paperclip with my rails 3 app. I want to append a random
I am using paperclip to upload files to s3 storage. Once the file is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.