Questions tagged [paperclip-validation]
89 questions
13
votes
1 answer
Paperclip/Rspec tests: Is there a faster way to test paperclip validates_attachment_content_type?
One thing I've noticed is that in most of the projects I do, the one spec that always takes a long time (30 seconds +) is this shoulda/paperclip helper:
it { should validate_attachment_content_type(:bannerimage)
.allowing('image/png',…

PlankTon
- 12,443
- 16
- 84
- 153
13
votes
2 answers
ImageMagick installation in Docker Alpine
So I have this Dockerfile that attempts to install ImageMagick the following way:
FROM ruby:2.4-alpine
...
RUN apk --update add imagemagick
...
The point is that the container doesn't recognizes the file utility (for content-type…

Fdo
- 1,053
- 4
- 15
- 38
10
votes
2 answers
Paperclip in Rails 4 - Strong Parameters Forbidden Attributes Error
Having a problem with a Paperclip upload in Rails 4 - failing on ForbiddenAttributesError (strong parameters validation). Have the latest paperclip gem and latest rails 4 gems.
I have a model "Image" with an attached file "upload" in the…

Eskim0
- 775
- 7
- 17
9
votes
3 answers
Paperclip- validate pdfs with content_type='application/octet-stream'
I was using paperclip for file upload. with validations as below:
validates_attachment_content_type :upload, :content_type=>['application/pdf'],
:if => Proc.new { |module_file| !module_file.upload_file_name.blank?…

Pravin
- 6,592
- 4
- 42
- 51
9
votes
1 answer
Validate extension in Paperclip - Ruby on Rails
I've found that Paperclip can validate file content type, i.e. image/jpeg, but I want to specifically validate the extension. This is because I'm working with an obscure extension that won't get a consistent content type. Anyone know if this is…

Geoff
- 9,470
- 13
- 52
- 67
9
votes
1 answer
Validate multiple content-types with Paperclip and Rails
I'm using the Paperclip gem for Rails in order to allow users to upload a photo of themselves. I obviously only want to accept jpeg, gif or png images. What is the proper way to validate these files were uploaded instead of something else like a…

at.
- 50,922
- 104
- 292
- 461
8
votes
1 answer
Rails paperclip, Edit form file_field not assigned
I used paperclip to attach an avatar onto my user, in my Model:
has_attached_file :avatar,
:styles => {square_tiny: '50x50#', square_small: '100x100#', square: '200x200#'}
I have a form
<%= form_for(@user_profile,
:url => {…

zabumba
- 12,172
- 16
- 72
- 129
7
votes
3 answers
Paperclip photo upload fails in IE8
I'm using paperclip to upload image in my app. The validation I've is :
validates_attachment_content_type :image, :content_type => ['image/jpg','image/jpeg', 'image/png', 'image/tiff', 'image/gif']
Everything works well in firefox, chorme and IE9.…

safalmj
- 692
- 1
- 5
- 16
7
votes
2 answers
Paperclip image dimensions custom validator
This is my Image model, in which I've implemented a method for validating the attachment's dimensions:
class Image < ActiveRecord::Base
attr_accessible :file
belongs_to :imageable, polymorphic: true
has_attached_file :file,
…

Agis
- 32,639
- 3
- 73
- 81
6
votes
1 answer
Why some of the MP4 file's mime-type are application/octet-stream instead of video/mp4?
Why some of the MP4 file's mime-type are application/octet-stream instead of video/mp4?
I've checked with file command in terminal (CLI)
user@anto:~/Videos/VTB$ file --mime-type -b GDPR.mp4
video/mp4
user@anto:~/Videos/VTB$ file --mime-type -b…

ARods
- 441
- 2
- 5
- 13
6
votes
1 answer
How to upload an Outlook file ( .msg extension) using the Paperclip gem in Rails
I need to be able to attach emails to a model, specifcally .eml and .msg files
Paperclip now requires validations of the types of files upload with it.
The section of my code where those validations live is here:
validates_attachment_content_type…

Garrett Simpson
- 1,471
- 2
- 17
- 18
5
votes
1 answer
Checking if a paperclip attachment exists within a view.
Check whether a Paperclip attachment exists:
I'm trying to see if the attachment has selected a file/image then something will happen like this new view to appear. So after i click browse select an Image I want something to happen!! Thanks! …

Michael Lombardo
- 457
- 4
- 20
5
votes
1 answer
Paperclip for both images and Videos
In my app I already have paperclip for upload images, but requirement changed in order to accept both images and videos. The images are already defined in a model with a belongs_to relationship, called Attachment. Since the video will also be an…

tvieira
- 1,865
- 3
- 28
- 45
4
votes
1 answer
WARNING: Can't mass-assign protected attributes Paperclip Rails 4
I am trying to use paperclip to upload images to amazon S3 using heroku. And so far I am getting : WARNING: Can't mass-assign protected attributes for User: picture. I have been through many guides and none helped.
My model:
class User <…

Henrique Dantas
- 41
- 2
4
votes
1 answer
Paperclip: Content Type Spoof trying to upload .gpx files
Apologies if this has been answered and I failed to find it. Any direction would be greatly appreciated.
Using Rails 4.1.4, Paperclip 4.2.0 and Simple Form 3.0.2.
After Submit, I get has an extension that does not match its contents output in the…

Paul Y
- 193
- 3
- 9