使用 Ruby,我只是尝试将比特流文件解析到服务器,我遇到了 badrequst HTTP 的问题。任何人都可以帮助我使用 Net::HTTP 将数据发送到服务器。
def addbitstream(url, path, file_bitstream)
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, 443)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(path)
f = File.new(file_bitstream)
file = File.open(f)
n = 6
offset = 0
request.body = ""
while (offset < File.size(file))
buffer = readfileAsbitstream(file, offset, n)
request.body = buffer
response = Net::HTTP.start(uri.host, 443) {|http| http.request(request) }
offset += n
end
end