Как отправить файл с помощью axios методом post чтобы сохранить на сервере VK?
Мне нужно отправить файл формата .txt
Код:
let text = "File: File"
var fs = require('fs');
fs.writeFile('tempfiles/temp.txt', text, (err) => {
if (err) throw err;
}); // Сохраняю файл temp.txt в папке tempfiles
vk.api.docs.getMessagesUploadServer({type: `doc`, peer_id: message.peerId})
.then(res => { //Получаю ссылку для post запроса на сервер
let link = res.upload_url
var formData = new FormData(); // ну это понятно
formData.set("file", "./tempfiles/temp.txt") // подозрение на эту часть
axios.post(link, formData, {
headers: {
'Content-Type': 'multipart/form-data'
},
}).then(function (response) {
console.log(response.data)
}) // отправил запрос в формате, который нужен для вк (multipart/form-data)
})
Получаю ошибку:
{
error: 'ERR_UPLOAD_BAD_SIGNATURE',
bwact: 'add_doc_new',
server: 236331,
_sig: '533dd4090a031c8f03791ff7571ff741'
}