I am using rails server. i am sending core http request. in request.body contents a file which I want to be uploaded. This request.body is StringIo object. I want to upload this file to my server.
+2
A:
This writes the file to disk in 1mb (1024**2) chunks. Reading the whole file in at once can leave you open to a DOS with huge files.
File.open("where-you-want-the-file", "w") do |f|
while blk = request.body.read(1024**2)
f << blk
end
end
cwninja
2010-01-21 09:46:31