paperclip

Which is the proper way to upload an image from an external url with Paperclip on rails 4?

北城以北 提交于 2019-12-13 20:47:56
问题 I want to download to a MOdel the image from an url: I already read Save image from URL by paperclip but first I run into this error: Paperclip::Error: Page model missing required attr_accessor for 'picture_file_name' afterwards , I added the attr_accessible parameter and run into this other error: RuntimeError: `attr_accessible` is extracted out of Rails into a gem I now added also the protected_attributes to no success.. This is how my model is reading right now: require 'open-uri' class

Paperclip::Attachment passed as string when using FactoryGirl

旧城冷巷雨未停 提交于 2019-12-13 19:13:29
问题 I am trying to create a functional test for paperclip 3.1.2 on rails 3.2.6 using FactoryGirl 3.0 and when i pass the file attachment my controller receives a string which is the file location and not the Paperclip::Attachment object. My factory is: include ActionDispatch::TestProcess FactoryGirl.define do factory :artist do id 1 name 'MyString' photo {fixture_file_upload("#{Rails.root}/test/fixtures/files/rails.png",'image/png')} end end And my test is: test "should create artist" do assert

Paperclip processor timeout on S3

别等时光非礼了梦想. 提交于 2019-12-13 18:28:05
问题 I'm inserting a digital signature into a pdf file inside my processor, but keep getting an AWS::S3::ERRORS::Requestimeout error. What is this timeout? Is there any way i could keep the connection open until the file gets uploaded ? Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed. Here is my code : model: ... has_attached_file :receipt_file, :storage => :s3, :s3_credentials => "#{Rails.root}/config/s3.yml", :path =

Paperclip::NotIdentifiedByImageMagickError when file is not a valid attachment content type

≡放荡痞女 提交于 2019-12-13 16:50:23
问题 I have systematically an error when I'm trying to upload a file that is not in ["image/jpg", "image/jpeg", "image/gif", "image/png", "image/pjpeg", "image/x-png"] When I try to upload a file like a 'wav' I have this message * Photo /var/folders/nT/nTr21TWfFRO7r3cyG-h-7++++TM/-Tmp-/Clip audio 01,39154,0.wav is not recognized by the 'identify' command. * Photo /var/folders/nT/nTr21TWfFRO7r3cyG-h-7++++TM/-Tmp-/Clip audio 01,39154,0.wav is not recognized by the 'identify' command. * Photo content

Rails: uploading files with paperclip

眉间皱痕 提交于 2019-12-13 14:44:25
问题 I would like to use paperclip to upload files. With the basic out of the box settings, I was able to get the file uploaded to the default directory (something in public/systems...) However when I tried changing the url or path (or both): class Cvit < ActiveRecord::Base has_attached_file :fileup, :path => ":rails_root/public/data/01_fasta" end I lose permission to the 01_fasta directory, after doing a chmod 777 on it, I notice the file is there but its named something like, stream20110706

Custom URL with Paperclip and AWS S3

◇◆丶佛笑我妖孽 提交于 2019-12-13 13:07:17
问题 We're using Paperclip with the aws-sdk gem to store and display images in our Rails app: class User < ActiveRecord::Base has_attached_file :image, storage: :s3, s3_credentials: 'config/s3.yml', s3_protocol: :https, styles: { curriculum: '120x120>', medium: '600x600>', thumb: '200x200>' }, default_url: 'missing_photo.png' end If I then use <%= image_tag current_user.image.url %> in an html.erb file, I get the following HTML: <img src="https://s3.amazonaws.com/<my_bucket>/users/images/000/000

Status code 422 Unprocessable Entity - Paperclip, ImageMagick & Rails 3

蹲街弑〆低调 提交于 2019-12-13 12:21:48
问题 I am not sure what's causing this and would love some insight: Started POST "/uploads.js" for 127.0.0.1 at 2011-02-21 09:14:36 -0500 Processing by UploadsController#create as JS Parameters: {"name"=>"DSC_0561.JPG", "chunk"=>"0", "chunks"=>"1", "upload"=>{"stage_id"=>"16"}, "authenticity_token"=>"SfNGZm4lP56eG94OliSo2Kk9Tikg+X2pHaGoRLdbUmg=", "file"=>#<ActionDispatch::Http::UploadedFile:0x000001080f7ce8 @original_filename="DSC_0561.JPG", @content_type="application/octet-stream", @headers=

How to retrieve EXIF information of an image in Rails

喜欢而已 提交于 2019-12-13 11:38:34
问题 I am using Rails paperclip for displaying the images in my page. I want to know how to retrieve EXIF information of an image(like dimensions, camera model,height,width., etc).Can any one help me out??? Thanks!!! 回答1: Did you give exifr gem a try? From the documentation EXIFR::JPEG.new('IMG_6841.JPG').width # => 2272 EXIFR::JPEG.new('IMG_6841.JPG').height # => 1704 EXIFR::JPEG.new('IMG_6841.JPG').exif? # => true EXIFR::JPEG.new('IMG_6841.JPG').model # => "Canon PowerShot G3" EXIFR::JPEG.new(

Download file on click - Ruby on Rails

北战南征 提交于 2019-12-13 11:36:48
问题 My application is using Rails 2 backend, Heroku for hosting, Paperclip for file uploads, and Amazon S3 for file storage. Right now users can upload files with paperclip + s3 - this works flawlessly. After upload, an icon appears on their dashboard, linked to the file location (in s3 bucket). When the icon is clicked, the browser opens the file in a new window (for most file types - PDF, MP3, img, etc). Instead of opening, I want the file to be automatically downloaded when the user clicks the

Open a paperclip attached word doc in Ruby/rails

人走茶凉 提交于 2019-12-13 08:57:50
问题 I have a rails app with file attachments using paperclip. Images and pdfs work fine in that if I click on the linked attachment, the image or pdf opens. If I right click, I can do a save-as. However, with Office files such as word.docx, I can only download the file. If I go do Dos and type the filename, it will open in MS word. Therefore, I think that I should be able to use the system or system call and just pass the attachment name from paperclip (ie attachment.image.url) to dos and the