Archive for the 'upload' Category

02
May
09

a rails tip about uploading


I’ve just spent the last 6 hours trying to debug a “rails ioerror in MyFileController#create closed stream”. I’ve tried running the code in webrick, then in mongrel.
I started with rails 2.0.2, then I’ve upgraded to 2.3.2 . I had some minor incompatibilities between rails versions, but I took care of them.

The thing was, I had an upload form, which was filled out by a java client. I’m building a backup application using rails+java . It works this way : if you want to backup a file, the client just uploads it through the form; if you want to upload a folder, all the files within get recursively uploaded . After about 10 files ( in webrick ), and 20-30 ( in mongrel ), the error I mentioned above started to show.

I was out of ideas on what to try. I read on the mongrel site that mongrel can be run in a “debug mode” which generates helpful debug information, and I said to myself “why the heck not?”. I was kind of amazed to see that the error didn’t appear, even after 40 uploaded files, so I was thinking that mongrel does stuff on your behalf, affirmation which I now consider true. This landed an idea in my mind, the fact that I wasn’t closing the uploaded files after I was done with them.

I added an additional call to the close method, and the whole thing JUST WORKED !
I’m very proud of myself … I can almost overlook the fact that it took me 6 hours to figure this out!

Advertisements



Blog Stats

  • 229,299 hits