paperclip

Paperclip Amazon S3 setup with Heroku

拟墨画扇 提交于 2019-11-30 04:07:34
has_attached_file :image, :storage => :s3, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml", :path => "/:style/:filename" I'm not sure what :path => "/:style/:filename" is. I also want to to include the style for this attached image, is that what the :path is? the style I want is this: :styles => { :medium => "275x275>", :thumb => "175x155>" } Basically what's going on here is that I'm setting up on heroku and I'm having to use S3 which seems straightforward just not used to this attachment convention stuff. Also, I just signed up for an S3 account... but heroku was spouting that its free or

Rails 3 - Amazon S3 Paperclip EU Problem

你说的曾经没有我的故事 提交于 2019-11-30 03:53:47
I'm using: Paperclip 2.3.16 Rails 3.0.9 Ruby 1.9.2 AWS - S3 0.6.2 I'm trying to use paperclip the upload to the EU (Ireland) based bucket. I have the following in my model: has_attached_file :image, :styles => { :grid => '90x128#', :list => '140x200#', :original => '400x548'}, :storage => :s3, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml", :url => 'flyers/:id/:style/:basename.:extension', :path => 'flyers/:id/:style/:basename.:extension', :bucket => 'fsight' In my environment.rb I have set the write to use the AWS/s3 Default Host to the relevant EU one by using: require "aws/s3" AWS::S3:

Ruby on Rails 4 - Paperclip AWS Image URL is wrong?

允我心安 提交于 2019-11-30 03:51:23
问题 I've used paperclip and AWS together before, but I just created this Rails 4 app, and my image.url method is showing looking for the image at 'http://s3.amazonaws.com/', when it should be looking for them at 's3-us-west-2.amazonaws.com'. I'm assuming this is because the region for the first account is US Standard, whereas the new one is Oregon. Any way for me to change the region in the config files or something? 回答1: Apparently there used to be a bunch of workarounds for this, but now there

Paperclip Error: NotIdentifiedByImageMagickError

纵然是瞬间 提交于 2019-11-30 03:08:53
问题 I've had a rails install with Paperclip working just fine for a while now and in a recent deploy it has broken. I believe it coincided with a gemfile update, because nothing else on the machine has changed. The error is: Command :: file -b --mime :file [paperclip] Error while determining content type: Command 'file -b --mime :file' returned 1. Expected 0 This is on a png file that I've verified to be valid. When I run 'file -b --mime' on the image I get: image/png; charset=binary I also get

Get absolute URL for paperclip attachment

主宰稳场 提交于 2019-11-30 03:02:20
Is it possible to get the absolute URI for a Paperclip attachment? Right now, the problem is that the production environment is deployed in a sub-URI (on Passenger: RackBaseURI ), but <paperclip attachment>.url returns the Rails-app relative URI ( /system/images/... ). Is there a way to get the absolute URI for Paperclip attachments? I'm using Paperclip v2.7 and Rails 3.2.8. kuboon try URI.join(request.url, @model.attachment_name.url) or URI(request.url) + @model.attachment_name.url It's safe if you use S3 or absolute url. Update: this answer is better than mine ;) https://stackoverflow.com/a

ruby copy a paperclip attachment from one model to another?

我们两清 提交于 2019-11-30 00:45:35
问题 I have two models like this:- Model 1 - card - contains a representation of data of interest for front page attachment name = cardimage Model 2 - user - contains the user attachment name = avatar When I create! a new card, I want the avatar from the user model to be copied to the card model as a new cardimage. Is there a simple one liner for this? Ruby/Rails/Paperclip 回答1: This should do the trick, you could use an after_create callback if the models are associated, if not I would recommend

Paperclip - rename file before saving

时光总嘲笑我的痴心妄想 提交于 2019-11-30 00:27:17
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 added the file type, instead of 1334487964.jpg is saved only 1334487964. . What I missing there? I thought :file_name contains only the file name - without the file type This is the way how I fix my issue: def rename_avatar #avatar_file_name - important is the first word - avatar - depends on your column in DB table extension = File.extname(avatar_file_name)

Getting width and height of image in model in the Ruby Paperclip GEM

为君一笑 提交于 2019-11-29 21:50:20
Trying to get the width and height of the uploaded image while still in the model on the initial save. Any way to do this? Here's the snippet of code I've been testing with from my model. Of course it fails on "instance.photo_width". has_attached_file :photo, :styles => { :original => "634x471>", :thumb => Proc.new { |instance| ratio = instance.photo_width/instance.photo_height min_width = 142 min_height = 119 if ratio > 1 final_height = min_height final_width = final_height * ratio else final_width = min_width final_height = final_width * ratio end "#{final_width}x#{final_height}" } },

Rails Paperclip Plugin - Style Options for Resizing

[亡魂溺海] 提交于 2019-11-29 20:59:37
So, I want to resize images to a FIXED width, but proportional height. I have been trying a wide range of operators: 380x242# 380x242> 380!x242 380x242< none of them have the desired effect. Any help? I want it to fill or resize to the 380 width, then resize / shrink the height by the same factor it used to shrink or resize the image to 380 wide. Try using 380x This should resize width to 380px and keep original aspect ratio. For all available options for resizing images go here: http://www.imagemagick.org/script/command-line-processing.php?ImageMagick=lj6pre8q2iautc3ch6nuph1fc2#geometry "#"

paperclip working in development but not working in production?

ぐ巨炮叔叔 提交于 2019-11-29 20:55:50
问题 I'm pretty new to rails and seem to be having an issue with the paperclip gem. I installed the gem and it works well in development (localhost:3000) but when I'm running it on the heroku server, for some reason it does not want to attach files, and the app breaks (error 500 page). Here is the process i ran... I pushed my file to heroku, heroku ran rake db:migrate (to add paperclip migrations), and then I ran heroku restart (to restart the app with new migrations). This did not seem to help.