ladjs / superagent

Ajax for Node.js and browsers (JS HTTP client). Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.
https://ladjs.github.io/superagent/
MIT License
16.56k stars 1.33k forks source link

url pdf file with filename attached put request #1733

Open daskabe opened 2 years ago

daskabe commented 2 years ago

i have a pdf file url. i need to send it with superagent with fileName param. is there example of this? this is not working

 const urlf = 'http://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf';

  const s = await http.get(urlf, (stream) => {
    return stream;
  });

  let req = superagent
    .put(`${url}/attachFile`)
    .auth(apiUserName, password)

  req.attach('fileName', "dummy.pdf");
  req.pipe(s)
    .end(() => {
      console.log("attachement upload")
   })