0

I 'm using Paperclip to upload Images to Amazon S3 in Ruby on Rails. Its working fine, Images save & display well But the url is Like

http://MYBUCKET.s3.amazonaws.com/users/avatars/12/medium_Noor.jpg?1456223556 I want to know that how this query ?1456223556 string appended in path Is it happening due to S3 or something I 've done in Code

in Config/initializers/paperclip.rb

Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id/:style_:filename'
Paperclip::Attachment.default_options[:s3_host_name] = 's3.amazonaws.com'

In Model

  has_attached_file :avatar, styles: { medium: "500x500>", small: "250x250#", thumb: "100x100>" },
                        default_url: "/images/:style/missing.png",
                        storage: :s3,
                    s3_credentials: "#{Rails.root}/config/aws.yml"

  validates_attachment_content_type :avatar, content_type: /\Aimage\/.*\Z/

and in Controller

def create
    @user = User.create( user_params )
    if @user.save
            redirect_to users_path
        else
            render :new
        end
  end

  private
  def user_params
    params.require(:user).permit(:avatar)
  end
Muhammad Faisal Iqbal
  • 1,796
  • 2
  • 20
  • 43

0 Answers0