不确定如何将FormData转换为实际文件。特别是图像
class Post < WEBrick::HTTPServlet::AbstractServlet
def do_GET(request, response)
File.new("1.png") if request.query["image"]
# request.query["image"] is a FormData object
# how do I interpret it and turn it into a usable file?
end
end
..后来用于服务器挂载
server.mount '/post', Post
答案 0 :(得分:1)
从此blog post:
def do_POST(req, res) filedata= req.query["filename"] f = File.open("foo.out", "wb") f.syswrite filedata f.close puts "Saved file OK" end