{
"body": "Unsupported method.",
"code": "400",
"message": "",
"res": {
"connection": [
"close"
],
"content-length": [
"19"
],
"content-type": [
"text;charset=ISO-8859-1"
],
"date": [
"Mon, 20 Sep 2021 05:37:36 GMT"
]
}
}
进入空气制动器时出现上述错误
uri = URI(URL it is constant)
req = Net::HTTP::Post.new(uri)
req.set_form(['upload', File.open("#{file_name}")], 'multipart/form-data')
req.set_form_data("mac" => mac)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
res = http.request(req)
case res
when Net::HTTPSuccess, Net::HTTPRedirection
Rails.logger.info "File sent successgully"
# OK
else
Airbrake.notify("File transfer failed !", {code: res.code, message: res.message, body: res.body, res: res})
2条答案
按热度按时间j2cgzkjk1#
这对我很有效
6ioyuze22#
我们有一个类似的用例,最后使用了Net::HTTP::Post