【问题标题】:Sending Binary Data with Postman and Newman使用 Postman 和 Newman 发送二进制数据
【发布时间】:2017-01-27 07:36:09
【问题描述】:
【问题讨论】:
标签:
file-upload
postman
newman
【解决方案1】:
这是您在请求中需要的内容。我不得不从保存的集合中修改 src
{
"name": "Room Document",
"request": {
"url": "{{url}}/api/v1/folders/321/documents",
"method": "POST",
"header": [
{
"key": "Accept",
"value": "application/json",
"description": ""
},
{
"key": "Authorization",
"value": "3242349-324432-23423423-23424",
"description": ""
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "file",
"type": "file",
"src": "blank.pdf"
}
]
},
"description": " "
},
"response": []
},
【解决方案2】:
我像这样使用它,它与二进制文件一起工作:
"body": {
"mode": "file",
"file": {
"src": "path/to/your/file.jpg"
}
}
这样您就不必设置 KEY、Type 等。但是您需要在 Header 中将其设置为
Content-Disposition: attachment; filename="file.jpg"
在我们的例子中
Content-Type: application/octet-stream