2010-11-19 7 views
4

Ich benutze Schienen 3 und Büroklammer. Meine Logik erlaubt dem Benutzer, ein Bild hochzuladen. Dies funktioniert einwandfrei, es sei denn, der Benutzer wählt eine Datei aus, die kein Bild ist.Büroklammer - Fehler beim Hochladen des Bildes: "wird vom Befehl 'identifizieren' nicht erkannt."

Wenn der Benutzer eine Textdatei, nimmt zum Beispiel der Validierung Pässen sondern endet mit diesem Fehler up:

5 errors prohibited the profile update: 

Profile pic content type is not one of image/jpeg, image/png, image/gif 
Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-17xuiu4-0.js is not recognized by the 'identify' command. 
Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-17xuiu4-0.js is not recognized by the 'identify' command. 
Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-17xuiu4-0.js is not recognized by the 'identify' command. 
Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-17xuiu4-0.js is not recognized by the 'identify' command. 

Zumindest der erste Fehler bezieht sich auf den Dateityp. Aber wenn die Börse etwas speziellere Datei, wie ein .PXM, dann verhält sich Rails seltsam und zeigt dies:

4 errors prohibited the profile update: 

Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-1scwkg7-0.pxm is not recognized by the 'identify' command. 
Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-1scwkg7-0.pxm is not recognized by the 'identify' command. 
Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-1scwkg7-0.pxm is not recognized by the 'identify' command. 
Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-1scwkg7-0.pxm is not recognized by the 'identify' command. 

Weiß jemand, was hier vor sich geht? Ich habe den folgenden Code in meinem Modell:

validates_attachment_content_type :profile_pic, :content_type=>['image/jpeg', 'image/png', 'image/gif'] 

... und das Büroklammer initializer:

Paperclip.options[:command_path] = "/opt/local/bin/" 

ImageMagik erscheint korrekt installiert und eingerichtet werden:

$ which Magick-config 
/opt/local/bin/Magick-config 

Dank!

+1

Was bedeutet 'was identifizieren',' suchen identifizieren' oder 'finden/-name identifizieren' zurück? – Eric

+0

$ identifizieren /opt/local/bin/identifizieren – AnApprentice

+0

Ich reparierte dies mit Kokain 0.3.2. Weitere Informationen finden Sie unter http://stackoverflow.com/questions/12753157/paperclipnottiedibyimagemagickerror-in-spreeadminimagescontrollercre/12771707#12771707 –

Antwort

3

Ich hatte das gleiche Problem mit Paperclip und Rails 2.3.8. In der Deklaration has_attached_file Ihres Modells entfernen Sie die :styles für alle Nicht-Image-Dateien.

3

Geben Sie einfach den folgenden Code auf das Modell. Es wird keine Nichtbilddatei verarbeitet.

before_post_process :image? 
def image? 
    !(data_content_type =~ /^image.*/).nil? 
end 
Verwandte Themen