Answer the question
In order to leave comments, you need to log in
How to transfer a file using multipart in nodejs?
I'm trying to send a file to telegram, forming multipart via formData.
var formData = {
custom_file: {
value: fs.createReadStream('D:/node/Telegram/class.jpg'),
options: {
filename: 'class',
contentType: 'image/jpg'
}
}
};
request.post({url:myUrl, formData: formData}, function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
} else {
console.log('Upload successful! Server responded with:', body);
}
});
Server responded with: {"ok":false,"error_code":400,"description":"Bad Request: there is no photo in the request"}
Answer the question
In order to leave comments, you need to log in
Are you sure that in Telegram the file field is called custom_file?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question