1

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.

1
  • Can you please elaborate? If you have some code you've written that you are trying to get to work, we'd sure like to see it. Commented Jan 21, 2010 at 8:34

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.