Skip to content

Instantly share code, notes, and snippets.

@brstp
Last active December 13, 2015 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brstp/4951517 to your computer and use it in GitHub Desktop.
Save brstp/4951517 to your computer and use it in GitHub Desktop.
Still problem with special characters in filenames when Paperclip let´'s identify validate the file. Platform dependent. In my case, Win7. With reference to https://github.com/thoughtbot/paperclip/pull/1154 2013-02-14 10:20 CET
###########################################
# A. DEVELOPMENT ENVIRONMENT
# Win7/64
-------------------------------------------
# Excerpt from Gemfile.lock
GIT
remote: git://github.com/thoughtbot/paperclip.git
revision: e421bc1b0d5806f53be8a664c5f3c70c2e285e7e
specs:
paperclip (3.4.0)
activemodel (>= 3.0.0)
activerecord (>= 3.0.0)
activesupport (>= 3.0.0)
cocaine (~> 0.5.0)
mime-types
GEM
remote: http://rubygems.org/
specs:
climate_control (0.0.3)
activesupport (>= 3.0)
cocaine (0.5.1)
climate_control (>= 0.0.3, < 1.0)
mime-types (1.21)
rails (3.2.12)
fog (1.9.0)
PLATFORMS
x86-mingw32
-------------------------------------------
$ ruby -v
ruby 1.9.3p194 (2012-04-20) [i386-mingw32]
$ which identify
/c/Program Files (x86)/ImageMagick-6.8.0-Q16/identify
-------------------------------------------
# Excerpt from config/environments/development.rb
config.paperclip_defaults = {
:storage => :fog,
:fog_public => true,
:fog_directory => 'development.allom.se',
:fog_host => 'http://development.allom.se.s3-external-3.amazonaws.com',
:fog_credentials => {
:aws_access_key_id => ENV['S3_KEY'],
:aws_secret_access_key => ENV['S3_SECRET'],
:provider => 'AWS',
:region => 'eu-west-1'
}
}
-------------------------------------------
# Excerpt from app/models/organizer.rb
validates_attachment_content_type :logotype, :content_type => /image/
validates_attachment_size :logotype, :in => 0..10.megabytes
has_attached_file :logotype,
:default_url => "missing-organizer-logotype.png",
:path => "organizers/:attachment/:id/:style/:filename",
:styles => {
:medium => "256x256",
:small => "90x90"}
-------------------------------------------
# Manual test cases
1. Upload the file "lumano.gif".
Success
2. Upload the file "låmano.gif"
Fail. Error message:
Paperclip::Errors::NotIdentifiedByImageMagickError
# Excerpt from log/development
[495b9a0570d208456f4e735671b0ff94] [127.0.0.1] CACHE (0.0ms) SELECT "organizers".* FROM "organizers" WHERE "organizers"."slug" = 'jazz-pa-malaroarna' LIMIT 1
[495b9a0570d208456f4e735671b0ff94] [127.0.0.1]  (0.0ms) begin transaction
[495b9a0570d208456f4e735671b0ff94] [127.0.0.1] Command :: identify -format '%wx%h,%[exif:orientation]' "C:/Users/STEFAN~1/AppData/Local/Temp/låmano20130214-8520-147onsm.gif[0]"
[495b9a0570d208456f4e735671b0ff94] [127.0.0.1] [paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
[495b9a0570d208456f4e735671b0ff94] [127.0.0.1] Command :: identify -format '%wx%h,%[exif:orientation]' "C:/Users/STEFAN~1/AppData/Local/Temp/låmano20130214-8520-147onsm.gif[0]"
[495b9a0570d208456f4e735671b0ff94] [127.0.0.1] [paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
[495b9a0570d208456f4e735671b0ff94] [127.0.0.1]  (0.0ms) rollback transaction
[495b9a0570d208456f4e735671b0ff94] [127.0.0.1] User Load (1.0ms) SELECT "users".* FROM "users" INNER JOIN "memberships" ON "users"."id" = "memberships"."user_id" WHERE "memberships"."organizer_id" = 114 ORDER BY email
###########################################
# B. DEVELOPMENT ENVIRONMENT
# without S3 storage
-------------------------------------------
# Excerpt from config/environments/development.rb
config.paperclip_defaults = {
}
-------------------------------------------
# Manual test cases
1. Upload the file "lumano.gif".
Success
2. Upload the file "låmano.gif"
Fail. Error message:
Paperclip::Errors::NotIdentifiedByImageMagickError
###########################################
# C. STAGE ENVIRONMENT
# Heroku
Stack: cedar
-------------------------------------------
# Manual test cases
1. Upload the file "lumano.gif".
Success
2. Upload the file "låmano.gif"
Success
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment