-
Notifications
You must be signed in to change notification settings - Fork 24
Fails with ActiveRecord and CarrierWave uploader #46
Copy link
Copy link
Open
Description
Greetings, and thank you so much for all the work you guys put into the gem!
Now to the business... I have the following kind of model:
class VaultDoc < BaseModel
mount_uploader :document, VaultDocUploader
validates :document,
file_size: { less_than_or_equal_to: 25.megabytes },
file_content_type: { allow: ->(record) { record.allow_content_types }, mode: :strict },
on: :create
endWith the following kind of VaultDocUploader:
class VaultDocUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
storage :file
version :thumb, if: :thumbable? do
process resize_to_fit: [315, 445], if: :image?
process pdf_preview: [315, 445], if: :pdf?
end
def thumbable?(file)
image?(file) || pdf?(file)
end
def image?(file)
file.content_type.include? 'image'
end
def pdf?(file)
file.content_type == 'application/pdf'
end
end(There's a lot more to it, but seems to be irrelevant)
Validation raises an exception when I'm trying to create an instance of VaultDoc during tests:
NoMethodError: undefined method `eof?' for #<VaultDocUploader:0x00007feaa4a46168 @model=#<VaultDoc id: nil ...>, @mounted_as=:document, @staged=true, @file=#<CarrierWave::SanitizedFile:0x000000000d962d20 @file="/app/tmp/vault-cache/1691776062-272660352770104-0001-2145/logo.png", @original_filename="logo.png", @content_type="image/png", @content=nil>, @filename="logo.png", @cache_id="1691776062-272660352770104-0001-2145", @identifier=nil, @versions={:thumb=>#<VaultDocUploader::Uploader22380:0x000000000d960750 @model=#<VaultDoc id: nil, document: nil, state: "uploaded", title: "My Document", original_filename: nil, thumb_present: true, created_at: nil, deleted_at: nil, vault_keeper_id: "93419cd4-87ca-42ec-8ae4-ecfda99b7620">, @mounted_as=:document, @staged=true, @file=#<CarrierWave::SanitizedFile:0x000000000d96a8e0 @file="/app/tmp/vault-cache/1691776062-272660352770104-0001-2145/thumb_logo.png", @original_filename="logo.png", @content_type="image/png", @content=nil>, @filename="logo.png", @cache_id="1691776062-272660352770104-0001-2145", @identifier=nil, @versions={}, @format=nil, @parent_version=#<VaultDocUploader:0x00007feaa4a46168 ...>, @parent_cache_id="1691776062-272660352770104-0001-2145", @original_filename="logo.png", @geometry={:width=>315, :height=>315}, @cache_storage=#<CarrierWave::Storage::File:0x000000000a47d088 @uploader=#<VaultDocUploader::Uploader22380:0x000000000d960750 ...>, @cache_called=nil>>}, @format=nil, @original_filename="logo.png", @cache_storage=#<CarrierWave::Storage::File:0x000000000d961628 @uploader=#<VaultDocUploader:0x00007feaa4a46168 ...>, @cache_called=nil>> # /gems/file_validators-3.0.0/lib/file_validators/mime_type_analyzer.rb:27:in `extract_with_file' # /gems/file_validators-3.0.0/lib/file_validators/mime_type_analyzer.rb:16:in `call' # /gems/file_validators-3.0.0/lib/file_validators/validators/file_content_type_validator.rb:60:in `get_content_type'
This used to work on v2.3.0 and worked up to v3.0.0.beta1 (inclusive), whereas v3.0.0.beta2 and v3.0.0 (release) don't work.
Here are my thoughts on what's happened: https://github.com/musaffa/file_validators/pull/32/files#r1291636492
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels