问题
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