paperclip

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 I go about getting all of my uploads/attachments from S3 in a single zipped download? G...

Rails3 and Paperclip

Hi, I have migrated my application from rails 2.3 to rails3 and i have a problem with paperclip. I saw there was a branch for rails3 on paperclip git. So I added "gem 'paperclip', :git => 'git://github.com/thoughtbot/paperclip.git', :branch => 'rails3'" into the Gemfile and launch the command bundle install. Once paperclip installed, ...

How to find out an extension's content type?

Where could I find out the content type for a specific file format/extension? For example, I know that an mp3 can be one of the following content types: 'application/mp3', 'application/x-mp3', 'audio/mpeg', 'audio/mp3' What would be the content type for a zip file? Where would I find out that information for other content types? I ne...

allow_destroy in a form_for helper - Ruby on Rails

Can I use the 'magic' _destroy attribute that works for accepts_nested_attributes_for for a regular form_for helper? I have a file that I'm uploading via Paperclip and I'd like to have the option to delete it. ...

how to write this where paperclipe understands

I can do this command to resize an image to fit a specific size on the command line with Imagemagick. How do I tell paperclip can do the same when I upload an image: convert Bisiye2.jpg -thumbnail '150x150^' -gravity center -extent 150x150 Bisiye2_tofit.jpg ...

Paperclip plugin : Change image folder permissions

By default when I upload new images, the folder created have 777 permissions Is there a way to restrict permissions on the new folders? Thanks ...

Uploading files to S3 using paperclip, IOError (closed stream) error

Hey Guys, I am currently having issues uploading files to amazon S3 while using paperclip. It uploads half the files, and then chokes, with the error: IOError (closed stream) I have no idea what's causing this, any help would be really appreciated. Here's the stack trace: /opt/local/lib/ruby/gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/conne...

Resize an image with Paperclip [Rails]

The Paperclip plugin for Rails has a resize option that keeps the image in proportion. According to Ryan Bates' Paperclip Railscast, to make sure that option is on, you have to add a greater-than sign in the end of the size for the style you're looking to resize, as such: :styles => { :small => "160x160>" } I'm looking for Paperclip t...

Polymorphic Paperclip overwriting files with the same names

Hi, in Rails using the Polymorphic version of Paperclip, the default saving technique means that files with the same name overwrite each other. Including the :id in the path and URL doesn't work as it just overwrites the earlier file with the old :id. I've tried interpolations using a time-stamp, but it just looks for the current time w...

Attach 1 or more (non image) files to rails application, with having to install an image-processing library

Hi all, I'm currently learning rails by creating a simple project management app. I've gotten to the point where I would like to be allow a user upload multiple files - pdfs, docs, xls etc. The user only needs to be able to attach one file at a time, but the possibilty to have multiple documents associated with a project is a must. I'v...

Rails send_data() send_file() problem

Hello, I have a paperclip attachment in one model, but I`m not saving the file in /public, but /assets. And when the user what to open the file I use the send_data() function, which makes the user to download the file. My question is how can I show the file in other way (not nessecery to download)? So if the file is a image, I will see ...

Associating a default paperclip image from a different model

Here's some code, this is my NewsItem model as you can see... class NewsItem < ActiveRecord::Base belongs_to :country has_attached_file :image, :styles => { :original => '57x57' }, :default_url => '/images/football.png' # has_attached_file :image, # :styles => { :original => '57x57' }, # ...

Rails: Preventing Duplicate Photo Uploads with Paperclip?

Is there anyway to throw a validation error if a user tries to upload the same photo twice to a Rails app using Paperclip? Paperclip doesn't seem to offer this functionality... I'm using Rails 2.3.5 and Paperclip (obviously). SOLUTION: (or one of them, at least) Using Beerlington's suggestion, I decided to go with an MD5 Checksum c...

How to pass additional convert options to paperclip on Heroku?

class User < ActiveRecord::Base has_attached_file :photo, :styles => { :square => "100%", :large => "100%" }, :convert_options => { :square => "-auto-orient -geometry 70X70#", :large => "-auto-orient -geometry X300" }, :storage => :s3, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml", :path => ":attachment...

How can I set paperclip's storage mechanism based on the current Rails environment?

I have a rails application that has multiple models with paperclip attachments that are all uploaded to S3. This app also has a large test suite that is run quite often. The downside with this is that a ton of files are uploaded to our S3 account on every test run, making the test suite run slowly. It also slows down development a bit,...

Question about Paperclip for Rails

I'm using Papeclip(2.3.1.1) with Rails(2.3.5). In my view I write so: <%= link_to image_tag(p.attachment.url(:small)), p.attachment.url(:original) %>, and it becomes into href="/system/attachments/1/original/1.JPG?1270134617 (for a tag) src="/system/attachments/1/small/1.JPG?1270134617" (for img tag). And when I click on the pictu...

Overriding content_type for Rails Paperclip plugin

I think I have a bit of a chicken and egg problem. I would like to set the content_type of a file uploaded via Paperclip. The problem is that the default content_type is only based on extension, but I'd like to base it on another module. I seem to be able to set the content_type with the before_post_process class Upload < ActiveRecor...

Rails Paperclip XML POST File

I am able to 'POST' to a Rails application (with Paperclip) using XML instead of the standard web form (trying to do it from another Ruby script). However, I would like to include a binary file. Is there any way to include the binary data within an XML tag? Or can I do something like B64 encode the data on the client and then decode...

even small file upload stops activity on apache/rails

on my rails(2.3.5) app(currently 50-70rpm, maximum response time around 0.7s), uploading even 700k file(using paperclip plugin) locks up the server for web requests for everyone for 2 minutes! (other apps on same server work normally) does anyone have a clue why that might be happening? i am using some mysql transactions which lock the ...

Conditional Validation with Paperclip difficult

Hi, I have an "item", which goes through a multi-page creation process. Images are uploaded at step five, and I keep track of the steps by using the attribute "complete". When validating whether an image is attached with paperclip, I get problems using the code below: validates_attachment_presence :pic1, :if => Proc.new { |u| u.comple...