Forum: Ruby Image Uploads & Mechanize

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Ff13996efd0d3e14eaa39c6a13566716?d=identicon&s=25 Cole Walters (stockprogramming)
on 2014-05-11 01:20
I am trying to automate an image upload. The image appears to be
corrupted when I submit it. The documentation on the mechanize page
doesn't seem to work properly. So I did an image upload from chrome AND
the automated mechanize application. I compared the two with Fiddler2.
The ONLY difference I see is that when I submit the image from the
mechanize application I see a header and value called
"Content-Type-Encoding: binary". When I submit the image from within in
chrome the "Content-Type-Encoding" header is not there.

It works in Chrome
It DOES NOT work from within my automated application.

I right clicked saved as the image that was submitted from the
application so I could open it up in Notepad++. At the top of the file
image data is the..
"Content-Type-Encoding:binary"  I find this interesting. I removed this
line and it fixed the image. Somehow when I submit this image from
within my automated application it somehow gets this
"Content-Type-Encoding" line put in at the top???

So, how do I say to Mechanize.. when I call "form.submit", DO NOT
INCLUDE A HEADER called "Content-Type-Encoding". Since this is the only
difference that I see between the two.
Ff13996efd0d3e14eaa39c6a13566716?d=identicon&s=25 Cole Walters (stockprogramming)
on 2014-05-12 04:34
I found where the Mechanize Gem was hard coding file uploads with a
header of Content-Type-Encoding:binary

I removed it and now images are showing up. However, it appears as
though part of my image is corrupted.

This topic is locked and can not be replied to.