这个 cURL 请求的 HTTP 等价物是什么?我尝试翻译,但无法将文件正确传递给 API。
$ curl -F "file=@test.txt" https://xxxxxx
我试过了:
const formData = {
file: 'pathToFile'
}
request
.post({
url: 'xxxxxx',
form: formData
})
.on('response', (response) => {
console.log(response);
});
这给了我一个 5xx 服务器错误 ~ 文件参数未定义。
我将如何在 Node.js 中执行此操作?我正在使用请求