I'm trying to create a very simple program which upload image to the database using Paperclip in ROR. But the image can't go to the database everytime I press SUBMIT. Can anyone please point me where I did wrong.
This is my LOG File
Started POST "/users" for 127.0.0.1 at 2017-03-22 21:03:03 +1000
Processing by UsersController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"P1JjsD8GMBJbrAnOnc/RtTDDuVOCiv/z
sMhvM0Lzb3+bELWElYYN3FAVgERADmv8E1+dXK5nDais+LmmwaCa4Q==", "user"=>{"title"=>"eeee"
, "avatar"=>#<ActionDispatch::Http::UploadedFile:0xa40e398 #tempfile=#<Tempfile:C:/
Users/GaryVLC/AppData/Local/Temp/RackMultipart20170322-15228-psq6nh.jpg>, #original
_filename="14563434_519556131584166_3038665901337502288_n.jpg", #content_type="imag
e/jpeg", #headers="Content-Disposition: form-data; name=\"user[avatar]\"; filename=
\"14563434_519556131584166_3038665901337502288_n.jpg\"\r\nContent-Type: image/jpeg\
r\n">}, "commit"=>"Submit"}
Command :: file -b --mime "C:/Users/GaryVLC/AppData/Local/Temp/4233aadfd0ba434db17d
ee20d9613cee20170322-15228-tizi43.jpg"
[paperclip] Content Type Spoof: Filename 14563434_519556131584166_30386659013375022
88_n.jpg (image/jpeg from Headers, ["image/jpeg"] from Extension), content type dis
covered from file command: . See documentation to allow this combination.
(0.0ms) begin transaction
Command :: file -b --mime "C:/Users/GaryVLC/AppData/Local/Temp/4233aadfd0ba434db17d
ee20d9613cee20170322-15228-qcbjc3.jpg"
[paperclip] Content Type Spoof: Filename 14563434_519556131584166_30386659013375022
88_n.jpg (image/jpeg from Headers, ["image/jpeg"] from Extension), content type dis
covered from file command: . See documentation to allow this combination.
Command :: file -b --mime "C:/Users/GaryVLC/AppData/Local/Temp/4233aadfd0ba434db17d
ee20d9613cee20170322-15228-1l2s8em.jpg"
[paperclip] Content Type Spoof: Filename 14563434_519556131584166_30386659013375022
88_n.jpg (image/jpeg from Headers, ["image/jpeg"] from Extension), content type dis
covered from file command: . See documentation to allow this combination.
(0.0ms) rollback transaction
Rendering users/new.html.erb within layouts/application
Rendered users/new.html.erb within layouts/application (1.0ms)
Completed 200 OK in 108ms (Views: 53.3ms | ActiveRecord: 0.0ms)
Related
I'm just starting with Solidus, though I do know my way around Rails. I've created a Solidus project on my Mac, and I installed all the required gems as well as ImageMagick through Homebrew. Both identify and magick work as terminal commands as my /usr/local/bin directory is in my PATH. I've also specified the path to identify in the application.rb file (I'm guessing it's supposed to go in side the Application class). However, none of the images show up in Solidus, and when I try and manually add an image, I get the following error (it's related to paperclip). Any help here would be - Google has not been my friend this time. The error message is shown below:
[paperclip] Trying to link /tmp/RackMultipart20200622-9041-8gndhx.jpg to /tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-1t35lnu.jpg
[paperclip] Trying to link /tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-1t35lnu.jpg to /tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-62aumc.jpg
Command :: PATH=/usr/local/bin/identify:$PATH; file -b --mime '/tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-62aumc.jpg'
Command :: PATH=/usr/local/bin/identify:$PATH; identify -format '%wx%h,%[exif:orientation]' '/tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-1t35lnu.jpg[0]' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
Command :: PATH=/usr/local/bin/identify:$PATH; identify -format '%wx%h,%[exif:orientation]' '/tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-1t35lnu.jpg[0]' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
Command :: PATH=/usr/local/bin/identify:$PATH; identify -format '%wx%h,%[exif:orientation]' '/tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-1t35lnu.jpg[0]' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
Command :: PATH=/usr/local/bin/identify:$PATH; identify -format '%wx%h,%[exif:orientation]' '/tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-1t35lnu.jpg[0]' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
[paperclip] Trying to link /tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-1t35lnu.jpg to /tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-1dlkgdw.jpg
Command :: PATH=/usr/local/bin/identify:$PATH; file -b --mime '/tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-1dlkgdw.jpg'
[paperclip] Trying to link /tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-1t35lnu.jpg to /tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-16yjulo.jpg
Command :: PATH=/usr/local/bin/identify:$PATH; file -b --mime '/tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-16yjulo.jpg'
Rendering /Library/Ruby/Gems/2.6.0/gems/solidus_backend-2.10.1/app/views/spree/admin/images/create.js.erb
Rendered /Library/Ruby/Gems/2.6.0/gems/solidus_backend-2.10.1/app/views/spree/admin/images/create.js.erb (Duration: 3.4ms | Allocations: 874)
Completed 200 OK in 836ms (Views: 20.7ms | ActiveRecord: 7.6ms | Allocations: 29100)
This is what appear in my log:
Parameters: {"upload"=>#<ActionDispatch::Http::UploadedFile:0x7e20e68
#tempfile=#<Tempfile:C:/Users/bi/AppData/Local/Temp/2/RackMultipart20180116-3004-iw0tdo.jpg>,
#original_filename="Inkedmdb atualizado_LI.jpg", #content_type="image/jpeg",
#headers="Content-Disposition: form-data; name=\"upload\";
filename=\"Inkedmdb atualizado_LI.jpg\"\r\nContent-Type: image/jpeg\r\n">,
"ckCsrfToken"=>"AR65EsJdr219Nu21oN1Vlw8fc8XAJTc5ZTIQ1lg9", "CKEditor"=>"pop_objective",
"CKEditorFuncNum"=>"1", "langCode"=>"pt-br"}
Command :: file -b --mime "C:/Users/bi/AppData/Local/Temp/2/43a60d0ece9425495f704619dc133c4f20180116-3004-bkzljx.jpg"
Command :: identify -format '%wx%h,%[exif:orientation]' "C:/Users/bi/AppData/Local/Temp/2/242e48571825b96df1752e5c3933b2fd20180116-3004-1n87xt.jpg[0]" 2>NUL
I searched on internet end they suggested me to create a new file in the initializer to overwrite the method spoof or something like that, I created, and now the error changed, but still there.
Data content type is not valid
Does someone have any ideas, why that happening?
I solved, cleaned and precompiled the assets.
rails assets:clobber && rails assets:precompile
I'm using Paperclip with ActiveAdmin to upload pictures in Articles.
But I have a problem, when I'm editing an existing article, the first time after Webrcik started, it functions very well. But systematically, the second time I try to edit an article (whatever the one) Windows tells me that "file.exe" stopped to function, and " Internal Server Error Invalid argument - STDOUT " appears in the browser.
So, I restart webrick, and upload works only one time etc...
Here's the log :
Started PUT "/admin/articles/1" for 127.0.0.1 at 2012-10-24 18:11:45 +0200
Processing by Admin::ArticlesController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"VaB3lx3UZaOjUA6Yh+h8jG7ZExSQZDiyZUw6GYJQPbY=", "article"=>{"title"=>"ee", "desc"=>"ee", "content"=>"eeee", "photo"=>#<ActionDispatch::Http::UploadedFile:0x3cce7f0 #original_filename="Desert.jpg", #content_type="image/jpeg", #headers="Content-Disposition: form-data; name=\"article[photo]\"; filename=\"Desert.jpg\"\r\nContent-Type: image/jpeg\r\n", #tempfile=#<File:C:/Users/Greg/AppData/Local/Temp/RackMultipart20121024-6620-oorxwu>>}, "commit"=>"Update Article", "id"=>"1"}
[1m[35mAdminUser Load (0.0ms)[0m SELECT `admin_users`.* FROM `admin_users` WHERE `admin_users`.`id` = 2 LIMIT 1
[1m[36mArticle Load (1.0ms)[0m [1mSELECT `articles`.* FROM `articles` WHERE `articles`.`id` = ? LIMIT 1[0m [["id", "1"]]
Command :: identify -format %wx%h "C:/Users/Greg/AppData/Local/Temp/Desert20121024-6620-16n1ehl.jpg[0]"
Command :: identify -format %m "C:/Users/Greg/AppData/Local/Temp/Desert20121024-6620-16n1ehl.jpg[0]"
Command :: identify -format %m "C:/Users/Greg/AppData/Local/Temp/Desert20121024-6620-16n1ehl.jpg[0]"
Command :: convert "C:/Users/Greg/AppData/Local/Temp/Desert20121024-6620-16n1ehl.jpg[0]" -auto-orient -resize "510x" -crop "510x350+0+16" +repage "C:/Users/Greg/AppData/Local/Temp/Desert20121024-6620-16n1ehl20121024-6620-mvfl3a"
Command :: file -b --mime "C:/Users/Greg/AppData/Local/Temp/Desert20121024-6620-16n1ehl20121024-6620-mvfl3a"
[paperclip] Error while determining content type: Command 'file -b --mime :file' returned 255. Expected 0
Command :: identify -format %wx%h "C:/Users/Greg/AppData/Local/Temp/Desert20121024-6620-16n1ehl.jpg[0]"
Command :: identify -format %m "C:/Users/Greg/AppData/Local/Temp/Desert20121024-6620-16n1ehl.jpg[0]"
Completed 500 Internal Server Error in 22073ms
Errno::EINVAL (Invalid argument - ruby_setenv):
I've been searching for a solution...but I did not find one.
Does someone have an idea of the source of the problem ?
The 'file' program isn't a part of Windows, which suggests you installed it (or something that includes it) to get this far - any idea what that was? Gnu provides a Windows version of 'file' as part of GnuWin32.
Learning more about your copy of that program will probably be the first step to fixing your problem. (Hope this helps.)
When using CKEditor + Paperclip on rails 3 I get this error message when uploading an image via the wysiwyg editor:
Started POST "/ckeditor/pictures?CKEditor=question%5Banswers_attributes%5D%5B0%5D_body_editor&CKEditorFuncNum=2&langCode=en" for 127.0.0.1 at 2011-06-11 18:11:58 -0500
Processing by Ckeditor::PicturesController#create as HTML
Parameters: {"upload"=>#>, "CKEditor"=>"question[answers_attributes][0]_body_editor", "CKEditorFuncNum"=>"2", "langCode"=>"en"}
[paperclip] identify -format %wx%h '/var/folders/11/114evplqEWuTFgn6byOUQE+++TI/-Tmp-/stream20110611-1900-1hpvz8i.gif[0]' 2>/dev/null
[paperclip] An error was received while processing: #
[paperclip] identify -format %wx%h '/var/folders/11/114evplqEWuTFgn6byOUQE+++TI/-Tmp-/stream20110611-1900-1hpvz8i.gif[0]' 2>/dev/null
[paperclip] An error was received while processing: #
User Load (1.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY last_name ASC LIMIT 1
Rendered text template (0.0ms)
Completed 200 OK in 214ms (Views: 0.9ms | ActiveRecord: 1.2ms)
Is this a error with paperclip or?
Is identify installed (image magick) and in the PATH for your application?
(posting so question doesn't appear in unanswered list)
Edit: Forgot to mention this might need to go in environments/*.rb:
Paperclip.options[:command_path] = "/usr/local/bin" # or path to wherever identify is located.
i am trying to use apache bench to load test a create action in my rails application but ab doesn't appear to be sending the POST data - though it does correctly submit a POST and not a GET request.
this is the command i run:
ab -n 1 -p post -v 4 "http://oz01.zappos.net/registrations"
and this is the contents of the post file:
authenticity_token=M18KXwSOuIVbDPZOVQy5h8aSGoU159V9S5uV2lpsAI0
the rails logs show a POST request coming through but don't show any parameters being posted:
Started POST "/registrations" for 10.66.210.70 at Thu Sep 09 17:48:06 -0700 2010
Processing by RegistrationsController#create as */*
Rendered registrations/new.html.erb within layouts/application (14.0ms)
Completed 200 OK in 24ms (Views: 14.6ms | ActiveRecord: 0.1ms)
whereas a POST request coming from a browser results in this log entry:
Started POST "/registrations" for 192.168.66.20 at Thu Sep 09 17:49:47 -0700 2010
Processing by RegistrationsController#create as HTML
Parameters: {"submit"=>"true", "authenticity_token"=>"AfNG0UoTbJXnxke2725efhYAoi3ogddMC7Uqu5mAui0=", "utf8"=>"\342\234\223", "registration"=>{"city"=>"", "address"=>"", "name"=>"", "zip"=>"", "optin"=>"0", "state"=>"", "email"=>""}}
Rendered registrations/new.html.erb within layouts/application (13.7ms)
Completed 200 OK in 24ms (Views: 14.3ms | ActiveRecord: 0.1ms)
and finally, this is what ab logs for the request:
---
POST /registrations HTTP/1.0
User-Agent: ApacheBench/2.0.40-dev
Host: oz01.zappos.net
Accept: */*
Content-length: 63
Content-type: text/plain
---
why is it not picking up the post data?
if the "post" file is not there then i get an error message saying it can't find the file so i know at very least it is finding the file...
Maybe you need the -T option as stated in man ab:-
ab -n 1 -p post -v 4 -T application/x-www-form-urlencoded "http://oz01.zappos.net/registrations"
I tested with Django and it seem that Django don't really care about the content type header (it displayed the POSTed content whether I used -T or not) but Rails maybe want it.
Old question, but for the sake of anyone else who searches SO for this, here's how I got it to work.
Make EXTRA sure your post file is properly URL encoded with no extra non-printing characters or anything at the end. The most error-free way is just create it with code. I used some python to create mine:
>>> import urllib
>>> outfile = open('post.data', 'w')
>>> params = ({ 'auth_token': 'somelongstringthatendswithanequalssign=' })
>>> encoded = urllib.urlencode(params)
>>> outfile.write(encoded)
>>> outfile.close()
Example output:
auth_token=somelongstringthatendswithanequalssign%3D