Answer the question
In order to leave comments, you need to log in
How to send a file?
I receive pictures in base64 format on the service, I need to send them to another service via multipart/form-data, if I save the file to myself and send it in this way:
function sendFile(){
const opt = {
method: 'POST',
uri: 'path to service',
formData: { file: createReadStream('path to file') }
}
return requestPromise(opt);
}
Answer the question
In order to leave comments, you need to log in
function sendFile() {
const opt = {
method: 'POST',
uri: 'path to service',
formData: {
file: {
value: Buffer.from(image, 'base64'),
options: {
mimeType: 'image/jpeg',
filename: 'image.jpeg'
}
}
}
};
return requestPromise(opt);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question