Creating an IO ruby ​​object from request.body.read?

advertisements

I'm using sinatra and transloadit and sending files with xhr using valumns file uploader.

I need to create a IO object and fill it with data in request.body.read

How can I do that ? thank you.


Use StringIO:

require 'stringio'
StringIO.new(request.body.read)

Alternatively, can't you just pass request.body for your IO object?