开发者

Creating a ruby IO object from 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜