Still can't get request to get a PDF in the correct format

白昼怎懂夜的黑 提交于 2019-12-24 22:45:39

问题


I have been trying to write a NodeJS script that downloads a PDF file then attaches it in an email. The attachment that comes in the email is blank and says it can't be open. I have tried to follow the directions offered here request-promise download pdf file, but I still can't seem to get the right PDF to attach correctly. I have confirmed the pdfurl is valid and the file is not corrupt. This is what I have..Any help is much appreaciated

var pdfpath = "/tmp/test.pdf";
const options = {
  uri: pdfurl,
  encoding: null
};
request(options).pipe(fs.createWriteStream(pdfpath));

来源:https://stackoverflow.com/questions/57701302/still-cant-get-request-to-get-a-pdf-in-the-correct-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!