I am using Aspose to store a PDF, and that works well. I use S3 as my storage so if I download the file directly from S3 the file works fine. However, I cannot get a well formed PDF document when I’m using the node words api. What I’m doing is pretty simple, but the contents I get is never well formed and the file will not open with Preview on MacOS 12.5.1
Here is what I’m doing.
const downloadFileResponse = await wordsApi.downloadFile(
new model.DownloadFileRequest({
path: "/path/to/pdf/file.pdf",
storageName: asposeFileStorage,
})
);
fs.writeFileSync(
`/path/to/local/file/file.pdf`,
downloadFileResponse.body
);
“It may be damaged or a format that preview does not recognize” is the error I get trying to open the file after writing to disk.
This seems pretty simple, is there something obvious I’m doing wrong?