automation - 赛普拉斯:如何上传压缩的 tar 文件
问题描述
我正在自动化我的REST API。我有一个 POST 请求,例如:
POST /upload
文件(应用程序/x-compressed-tar)类型和
"Content-Type": "multipart/form-data"
.
cypressTestFile.ts
cy.fixture(filePath, 'binary').then((binary) => {
const blob = Cypress.Blob.binaryStringToBlob(binary);
const formData = new FormData();
formData.set('file', blob, filePath); <-- formData is empty {}
cy.request({
method: 'POST',
url: `/upload`,
form: true,
headers: {
"Content-Type": "multipart/form-data"
},
body: {
file: blob,
type: "application/x-compressed-tar"
}
}).as('response').then(res => {
expect(res.status).to.equal(201);
});
})
这没有按预期工作。
任何帮助表示赞赏!
谢谢
解决方案
推荐阅读
- django - Django - 从 POST 中获取值
- c - 如何从偏移量中提取特定位
- c++ - Clang:编译 C++ 时出错预期的成员名称或“;” 在声明说明符之后
- hyperledger-fabric - Hyperledger Fabric 中的恶意行为者?
- mysql - 如何在mysql中选择每组的百分比值
- python - 如何在python中合并标题列?
- shell - sh: 0: 无法在 jenkin 执行 shell 中打开
- java - 试图弄清楚如何在获得所有解决方案后停止这个 n 皇后方法,有什么方法可以解决这个问题?
- java - 如何使用 Jackson DataType: JSR310 Deser 独立?
- laravel - 日期解析在 laravel carbon 中不起作用