使用swagger发送二进制数据作为应用程序/八位字节流内容类型

时间:2018-11-08 20:52:43

标签: elixir swagger phoenix-framework

我无法以应用程序/八位字节流内容类型发送二进制数据。 以下是我添加到swagger_path的信息

swagger_path :create do
  post "/data"
  tag "POST Data"
  summary "POST data"
  description "Send data"
  consumes "application/octet-stream"
  produces "application/octet-stream"
  parameter :Body, :binaryData, :file, "The file to upload", required: true
  response 200, "Ok"
  response 400, "Bad request"
  response 401, "Unauthorized"
end

当我上传文件并执行命令时,看到以下错误

[info] module=Plug.Logger POST /data/
[info] module=Plug.Logger Sent 406 in 631µs
[debug] module=Plug.Debugger ** (Phoenix.NotAcceptableError) no supported media 
type in accept header.
Expected one of ["octet-stream"] but got the following formats:
* "application/octet-stream" with extensions: ["bin", "lha", "lzh", "exe",
"class", "so", "dll", "img", "iso"]

这是我要生成的curl命令

curl -X POST http://localhost:8000/data -H 'Content-Type: application/octet
stream'  --data-binary @conn.dat

0 个答案:

没有答案