Sending File to external API

Hi,

I need send uploaded file to external API. I need local storage address of file for this. My code:

let headers = {
“Authorization”: "Basic " + AUTHENTICATION_KEY,
“Content-Type”: "multipart/form-data; boundary=“test”,
“Accept-Encoding”: “gzip, deflate”
};

let msgBody = “–test\n” +
"Content-Disposition: form-data; name= " + filename + “; file=@” + file + “;\n–test–”;

let options = {
“method”: “POST”,
“headers”: headers,
“body”: msgBody
}

Can anyone suggest me which method I can for it or how can I get absolute path of file?

Thanks in advance

2 Likes