elixir - 使用 swagger 将二进制数据作为 application/octet-stream 内容类型发送
问题描述
我无法将二进制数据作为应用程序/八位字节流内容类型发送。以下是我添加到 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
解决方案
推荐阅读
- asp.net-mvc - 如何使用 Post 方法和 ViewBag 在视图中传递数据?
- android - Android WebView 键盘的下划线键下划线文字而不是正常工作
- html - HostListener OnClick 有时只工作
- java - Android:同时使用麦克风和耳机
- python - 是否有类似于neighbors() 的获取相邻边ID 的函数?
- html - 将选择作为文本附加到文本字段
- javascript - Uncaught (in promise) JavaScript - Skulpt 输入函数
- mediawiki - Mediawiki 清除作为用户权限
- function - as3 flash gotoAndPlay
- angular - 在 Angular 9 应用程序中从数据库加载组件脚本