Questions tagged [paperclip]

Paperclip is a library for the Ruby on Rails framework which makes dealing with file attachments easier. In addition to dealing with standalone files, the library provides convenience methods for creating image thumbnails. Paperclip is now deprecated - the authors recommend using ActiveStorage (they have provided a migration guide)

Paperclip is now deprecated. The library authors recommend switching to ActiveStorage. They have provided a migration guide as well.

Paperclip is intended as an easy file attachment library for ActiveRecord. The intent behind it was to keep setup as easy as possible and to treat files as much like other attributes as possible.

For more information:

4288 questions
16
votes
2 answers

paperclip - converting tiff images into jpg or png

I'm using paperclip to allow user to upload images and I want to convert an image into jpg/png only if it's a tiff image. I am using the following code in my image.rb: validates_attachment_presence :data validates_attachment_content_type :data, …
tanya
  • 2,925
  • 7
  • 32
  • 49
16
votes
2 answers

Rails, Getting a File's name when uploading a file to the server

I'm using an AJAX uploader in Rails 3, along with paper_clip and have files uploading here: def upload @photo = Photo.create({ :photo => params[:file], :title => params[:filename] }) respond_to do |format| format.json end …
user479959
  • 507
  • 1
  • 8
  • 17
16
votes
3 answers

Ruby on Rails - Paperclip Error

For reference I have been following this tutorial: https://devcenter.heroku.com/articles/paperclip-s3 Except I am in localhost testing right now, so I installed the Figaro gem and placed my S3 info in application.yml. Using Rails v4, Cocaine v0.5.3,…
Rachel9494
  • 849
  • 1
  • 7
  • 27
16
votes
3 answers

Ruby on Rails 4 - Duplicate paperclip validation messages

Is there any way to prevent validation messages appearing twice for Paperclip upload validations? Here is my model: has_attached_file :photo, :styles => { :thumb => "215x165" }, :default_url => "/images/:style/missing.png" validates_attachment…
jonny_FIVE
  • 457
  • 1
  • 4
  • 12
16
votes
2 answers

Using Paperclip within seeds.rb

Let's says I have the following entry in my seeds.rb file : Image.create(:id => 52, :asset_file_name => "somefile.jpg", :asset_file_size => 101668, :asset_content_type => "image/jpeg", :product_id => 52) If I seed it, it tries to process the image…
Ben
  • 5,030
  • 6
  • 53
  • 94
16
votes
5 answers

Allowing User to Download File from S3 Storage

Right now I am using Amazon S3 and Paperclip which is allowing my users to upload an image that is associated with the event they are creating. My ultimate goal is since others can view this event, to be able to click on the image and have it prompt…
RubyNewbie
  • 547
  • 5
  • 21
16
votes
2 answers

Paperclip S3 - Can upload images but cannot view them

I'm created a Rails app running on Heroku, with Paperclip and S3. I've managed to upload images to my S3 bucket through the site (I can see them show up in my bucket on the Amazon control panel). But when I add an Image tag i.e. <%= image_tag…
Misrab
  • 254
  • 2
  • 6
16
votes
3 answers

Paperclip - rename file before saving

I use this method for renaming the image before the saving: def rename_avatar self.avatar.instance_write :file_name, Time.now.to_i.to_s end before_post_process :rename_avatar The image is renamed by the current time, but there's not…
user984621
  • 46,344
  • 73
  • 224
  • 412
16
votes
3 answers

uninitialized constant AWS::S3::Base via AWS-SDK

This is an issue I'm having with the fact that after I upgraded to AWS-SDK (instead of aws-s3) with the newer version(s) of paperclip I can no longer call AWS::S3::Base.establish_connection! at all. Where ever in my code I call …
Keith Connolly
  • 386
  • 2
  • 9
15
votes
2 answers

How to detect if a paperclip attachment was changed in after_save callback?

It looks like Paperclip doesn't honor the ActiveRecord dirty model. How do I detect the change in after_save callback. class User has_attachment :avatar after_save :do_something def do_something if name_changed? # end …
Harish Shetty
  • 64,083
  • 21
  • 152
  • 198
15
votes
2 answers

Paperclip and Amazon S3 how to do paths?

How do I create paths with paperclip when using Amazon S3? My directory on my bucket is: /image/:id/:filename My model: has_attached_file :image, :storage => :s3, :bucket => 'mybucket', :s3_credentials => { :access_key_id =>…
Rails beginner
  • 14,321
  • 35
  • 137
  • 257
15
votes
5 answers

How to use Paperclip without a file, just with a string?

I have a rake file, that reads content via HTTP and I want to use Paperclip to store the loaded content on Amazon S3. It works fine when I provide a local file, but I would like to set the content as a string and set the content type manually. The…
Jan
  • 3,044
  • 3
  • 20
  • 32
15
votes
1 answer

Error: Validation failed: Images imageable must exist , rails-5.0 , paperclip-5

While i was trying to submit the form, following error occured: Validation failed: Images imageable must exist and render the same new.html.erb view. If i comment the file field in new.html.erb. Product is being created…
Waqas Awan
  • 554
  • 5
  • 14
15
votes
2 answers

Zip up all Paperclip attachments stored on S3

Paperclip is a great upload plugin for Rails. Storing uploads on the local filesystem or Amazon S3 seems to work well. I'd just assume store files on the localhost, but the use of S3 is required for this app as it will be hosted on Heroku. How would…
chaserx
  • 1,461
  • 1
  • 14
  • 13
15
votes
3 answers

Setting up bucket's name placed domain-style (bucket.s3.amazonaws.com) with Rails and Paperclip

Paperclip doc about url options: You can choose to have the bucket's name placed domain-style (bucket.s3.amazonaws.com) or path-style (s3.amazonaws.com/bucket). How would look like the setup to actually have bucket's name placed domain-style? I…
huoxito
  • 560
  • 6
  • 7