2

I am using paperclip to save images in s3. The following is the code in my model

has_attached_file :pic, :storage => :s3, :s3_credentials => "#{Rails.root}/config/s3.yml",
    :url => '/image/file/:basename.:extension',
    :path => '/image/file/:basename.:extension',
    :bucket => 'Test'

And the problem is whenever i save the image with same name, the image gets replaced if there is already an image with that name. I wanted to change the name of the file. I am saving the image during the creation of new item. So can i able to use the id of the item as name of the file so that the image will be unique? If yes then how can i do it? please help me.

1 Answer 1

3

This might help you:

Generating a unique file path with Polymorphic Paperclip

http://trevorturk.com/2009/03/22/randomize-filename-in-paperclip/

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. I was looking for the one like given in the first link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.