开发者

Creating a ruby IO object from request.body.read?

开发者 https://www.devze.com 2023-04-10 07:06 出处:网络
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

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 ? 开发者_如何学Gothank you.


Use StringIO:

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

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


Just use request.body, call request.body.rewind first.

0

精彩评论

暂无评论...
验证码 换一张
取 消