Questions tagged [paperclip-validation]

89 questions
1
vote
0 answers

Validate application/octet-stream MIME type for JPG with PaperClip Gem

My Rails 4.2.5 app is receiving JPG uploads from a mobile app. However, the MIME Type in the headers is: application/octet-stream PaperClip 4.3.2 returns the following error: [paperclip] Content Type Spoof: Filename 70221009989740.jpg…
fnllc
  • 3,047
  • 4
  • 25
  • 42
1
vote
0 answers

Paperclip content_type validation error only in production

Paperclip's content_type validation is behaving differently in my development environment and production environment, and I have no idea what might be causing this difference. I have a model with a paperclip attachment. It has this…
yerdua
  • 21
  • 6
1
vote
0 answers

How to upload a pdf and generate a JPG thumbnail of the first page

I'm on Rails 4 and I'm using Paperclip for file uploads. I'm desperately trying to build a feature that allows users to upload a PDF and generate an image preview (thumb) of the 1st page. The following code doesn't work. has_attached_file…
1
vote
2 answers

Store thumb image to specific directory in paperclip gem

Here is the code has_attached_file :image, :path => ":rails_root/public/images/:id/:filename", :url => "/images/:id/:filename", :styles => { :small => "300x168>", :large =>…
1
vote
2 answers

Paperclip Shoulda Matcher error (undefined method `gsub' for nil:NilClass)

I have an extremely weird issue where a test passes and fails randomly. Meaning, sometimes it'll pass and sometimes it'll fail. It's an issue with paperclip-matchers (https://github.com/thoughtbot/paperclip) with shoulda-matchers…
1
vote
1 answer

Rails Paperclip image upload not working on mobile

I'm creating a site that allows users to upload images from their mobile phones, through their browser. Before adding this feature to my site, I'm testing it out with a rails scaffold. To accomplish image upload, I'm using Paperclip 4.1. Image…
1
vote
2 answers

validates_attachment for optional field

I have an uload field which is optional, it can be left empty. But when it is is used, I want to validate the size and content of the attachment. So I use this validation in the model: validates_attachment :attachment, content_type: { content_type:…
John
  • 6,404
  • 14
  • 54
  • 106
1
vote
1 answer

uninitialized constant Paperclip::Error with paperclip-ffmpeg

I am using Paperclip , and paperclip-ffmpeg for processing uploads. Below is my code class Asset < ActiveRecord::Base belongs_to :profile has_attached_file :photo, :styles => { :mobile => {:geometry => "400x300", :format => 'mp4',…
Kashiftufail
  • 10,815
  • 11
  • 45
  • 79
1
vote
0 answers

Paperclip content_type validation

Is there a way to validate files based on content and not on extension in paperclip. If I rename a .dll file to .png and upload it. It passes the content_type validation but fails saying xxx.png is not recognized by the 'identify' command. Is there…
Pravin
  • 6,592
  • 4
  • 42
  • 51
1
vote
0 answers

Rspec/Paperclip: validation fails even with following documentation

Here is my validation: describe User it { should validate_attachment_size(:avatar).less_than(20.megabytes) } end Here is my User model: class User < ActiveRecord::Base validates_attachment :avatar, :content_type => { :content_type => /image/ },…
dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189
1
vote
1 answer

Rails - Paperclip - Multiupload - How to limit number of images?

I have a Rails 3.2 application using Paperclip to attach mutliple images in one fied. So, I have a Post model and a Image model. My question is: How to validate the number of image like the size validation of Paperclip? Thanks!
1
vote
3 answers

Ruby validation - multiple permutations for a single hash

Say there is a hash field that can have two possible value permutations, "foo" and "bar". How can I validate the hash value is one of the two? class ValidateMe validates :type => { :type => "foo" or :type => "bar" } end This results in an error.…
1
vote
1 answer

Running only paperclip validations in Rails

I've model Profile class Profile < Abstract has_attached_file :avatar, ... validates_attachment_size :avatar, :less_than => 2.megabytes validates_attachment_content_type :avatar, :content_type => ['image/jpeg',…
0
votes
1 answer

If-Statement with Paperclip | Ruby on Rails

I have to create 300px widht thumbnails if the file is a picture ('image/jpeg', 'image/png', 'image/gif') and no thumbnails if the file has an other extension. I'm using Paperclip for file-upload (it's working great without the conditions...). :file…
nenebale
  • 15
  • 3
0
votes
0 answers

Webp image upload issue in paperclip gem in ruby on rails

webp images upload not supported it's giving this error message when trying to upload webp images has below avatar_2_3_webp = open(image_ur) at paperclip method "open" we are getting this error ImageSpec::Error…