Corrupted Binary Uploads

11 views
Skip to first unread message

kallen

unread,
Jul 16, 2008, 5:47:29 PM7/16/08
to Ramaze
At my work we're working on a app in ramaze that requires uploads and
we've run into a game killing sort of snag. We're running the upload
example (after changing FileUtils.move to FileUtils.copy to get around
a permission error, probably due to windows' file locking) and
uploading any kind of image or other binary file results in
corruption, jpgs display as bizarre bands of color, zips won't open,
etc. The files look to be about .1Kb bigger. Plain text files seem to
work fine. We're running 2008.06 on XP, ruby 1.8.6. We tried webrick
and mongrel but neither helps. This happens on 3 different computers
so it's not an issue with one particular box. I'll keep digging around
for solutions, but any help resolving this would be appreciated.

Aman Gupta

unread,
Jul 16, 2008, 7:59:08 PM7/16/08
to ram...@googlegroups.com
What does the controller action you use to store these images look like? On windows, you have to make sure to include the 'b' flag whenever working with binary files.

  Aman Gupta

Michael Fellinger

unread,
Jul 17, 2008, 1:04:49 AM7/17/08
to ram...@googlegroups.com
On Thu, Jul 17, 2008 at 8:59 AM, Aman Gupta <themast...@gmail.com> wrote:
> What does the controller action you use to store these images look like? On
> windows, you have to make sure to include the 'b' flag whenever working with
> binary files.

i.e. File.open('foo.jpg', 'wb+'){|foo| foo.write(content) }

kallen

unread,
Jul 17, 2008, 10:14:41 AM7/17/08
to Ramaze
I tracked the bug back to the way rack opens temp files. It'll be
fixed in rack 0.4.
I monkey patched Tempfile to fix it in the meantime.
Reply all
Reply to author
Forward
0 new messages