visual-studio-code - 从 vscode RestClient 发送文件数组
问题描述
我在vsCode上使用 RestClient 来测试我的 API,并在后端使用Multer来保存文件。
我想知道有什么方法可以从 RestClient的 POST 请求中发送名为 productImages 的文件数组
解决方案
为了接受文件数组,您必须multer().array("productImages")
在路由中使用中间件,然后multer
将所有具有相同字段的表单数据添加name
到文件数组中,您可以从req.files
.
以下是上传 2 个文件的 restClient 发布请求:-
post http://localhost:4225/add-product-images
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="productImages"; filename="1.png"
Content-Type: image/png
< ../files/1.png
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="productImages"; filename="2.png"
Content-Type: image/png
< ../files/2.png
------WebKitFormBoundary7MA4YWxkTrZu0gW--
推荐阅读
- excel - 仅在 Excel 中查找和替换值(不在公式中)
- postgresql - 如何在 postgresql 函数中连接两个字符串?
- apache - htaccess 重定向有线问题
- json - JSON 模式中 $id 的推荐格式
- elasticsearch - 如何微调 Elasticsearch 6.8 中包含最多搜索词的搜索结果?
- python - 训练时改变高斯噪声层的Keras标准偏差
- excel - 查找查询来源的更简单方法?
- node.js - selenium chromedriver driver.get() 由于页面上的 websocket 而超时
- php - 我们应该用什么来测试存在
- python - 为什么在数据框的窗口转换后操作需要更多时间