paperclip

Multiple files uploading on Ruby on Rails 3 [closed]

丶灬走出姿态 提交于 2019-12-05 03:23:55
Closed. This question is off-topic . It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I would like to upload multiple pictures to my Rails 3 application. I am currently using Paperclip to upload a picture, and I have some post processing operations assigned to the model Photo. I saw some samples on the net (integrating uploadify, swfupload or some other libraries), but none was very detailed, and each one misses some steps. What is the simplest way to do this? A good JQuery uploader is jQuery

How can I use Rspec to test that a model using Paperclip is validating the size of an uploaded file?

别来无恙 提交于 2019-12-05 03:01:30
问题 The model: class Attachment < ActiveRecord::Base belongs_to :narrative attr_accessible :description, :user_id, :narrative_id has_attached_file :file validates_presence_of :user_id validates_presence_of :narrative_id validates_attachment :file, :presence => true, :size => {:less_than => 20.megabytes} end The test which doesn't work: describe Attachment do it { should validate_presence_of :file } it { should validate_size_of :file } # validate_size_of does not exist end I would like to avoid

Paperclip - Running a method after the file is saved?

霸气de小男生 提交于 2019-12-05 02:39:39
I'm working on a project that needs to accept file uploads. After the file is uploaded, I'm doing some processing - extracting information from the file. I eventually plan to run this in a background worker, but it's currently running inline. I've tried making use of both after_create and after_save to process the file, but it seems my method is ran before the save method from Paperclip - so my tests fail with "No such file or directory". Is there any way to trigger the save method early, or to somehow run my method after the file has been saved to the file system? You can't read paperclip

How to crop and then resize with Paperclip

本小妞迷上赌 提交于 2019-12-05 02:18:06
问题 I have a photo attachment which I'm saving using Paperclip. However, I'd like to process the photo first before saving by cropping it down and then resizing to the final size: e.g. I have a 900x900 photo, I want to first do a central crop to 500x500, and then resize the cropped photo down to a thumbnail size of 100x100. The purpose of this is so that the thumbnail image wouldn't simply be a scaled down version of the 900x900 since it might be too small to even make out anything in the photo.

ROR- Step by step multiple images using Paperclip

荒凉一梦 提交于 2019-12-05 01:34:22
问题 I have used the "tutorial" on here but for some reason it didn't work. Can anyone give me a step-by-step guide for setting up a multiple image form (upload) with other form elements ... Also another tutorial (a good one) may be provided. I only want to use the paperclip plugin. @Gordon Isnor: I have uploaded my current (noob) project with some functionality (login, register) but it's not even fine tuned a little. I'm only trying to get the multiple images working, all code of the "multiple"

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

╄→尐↘猪︶ㄣ 提交于 2019-12-05 01:25:05
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 end I want to set the photo's title as the photo's filename, but don't know how to, even though params[:file] does have the file and is being uploaded to S3. Any ideas? Thanks params[:file].original_filename has the filename you are looking for. params[:name] should have the name of the attachment and params[:mime_type] which shows the mime type will be available in the

Seed images in heroku with paperclip

荒凉一梦 提交于 2019-12-05 01:14:31
问题 When I run heroku run rake db:seed I get Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/image20130219-2-1gk1yip.png[0]' Command :: composite -gravity Center /app/public/media/watermark.png "/tmp/image20130219-2-1gk1yip.png[0]" -resize "1x1<" "/tmp/image20130219-2-1gk1yip.png20130219-2-1ng5f6c[0]" Command :: file -b --mime '/tmp/image20130219-2-1gk1yip.png20130219-2-1ng5f6c' Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/image20130219-2-1gk1yip20130219-2-t3caqg

Storing image using open URI and paperclip having size less than 10kb

巧了我就是萌 提交于 2019-12-05 00:49:08
问题 I want to import some icons from my old site. The size of those icons is less than 10kb. So when I am trying to import the icons its returning stringio.txt file. require "open-uri" class Category < ActiveRecord::Base has_attached_file :icon, :path => ":rails_root/public/:attachment/:id/:style/:basename.:extension" def icon_from_url(url) self.icon = open(url) end end In rake task. category = Category.new category.icon_from_url "https://xyz.com/images/dog.png" category.save 回答1: Try: def icon

Using Rails with Paperclip and SWFUpload

流过昼夜 提交于 2019-12-04 23:13:33
问题 I have a basic rails application test with a user model that has a photo field handled with paperclip. I created the views to be able to create/edit an user and the photo uploading is working nicely. <h1>Editing user</h1> <% form_for :user, @user, :url => user_path(@user), :html => { :method => "put", :multipart => true } do |f| %> <%= f.error_messages %> <p> <%= f.label :first_name %><br /> <%= f.text_field :first_name %> </p> <p> <%= f.label :last_name %><br /> <%= f.text_field :last_name %

Resize original image in Paperclip

早过忘川 提交于 2019-12-04 22:52:10
Paperclip stores original images in "original" folder. Is there a way to resize the original images? I want to make the originals smaller in order to save the disc space. So, for example, if visitor uploads a photo with 2592x1936 I want to store it as 1024x1024, the same way we set the dimensions for :thumb images in :styles Update (solved) I found out how to resize original images automatically on upload. One just needs to add :original to styles: class MyModel < ActiveRecord::Base has_attached_file :photo, :styles => { :original => "1024x1024>", :thumb => "150x150>" } end Caley Woods I'm not