I am fetching a PDF report from a third party API, and I want to upload that PDF directly to the s3. When I do that, it uploads PDF to s3, but for some reason when I open that PDF in s3, all pages are blank. I am doing something wrong? My code is as below.
var report = reportInfo.body;
const params = {
Key: 'report.pdf',
Body: report,
Bucket: process.env.S3_BUCKET_NAME,
ContentType: 'application/pdf',
};
s3.upload(params, (err, res) => {
if (err) {
console.log(err, 'err');
}
console.log(res, 'res');
});
I am assigning the response from API to the report object. One part of the response is looking like this:
'%PDF-1.5
%????
1 0 obj<</Length 2872/Filter/FlateDecode>>stream
x???n$?
?????~?0? @?&1???>x?6?f????PU?U?a???mf???V?D?yHQ????~$gF7?????_/?????/??[????=??v?????F?u???S3?d??k??:O?????X?k???2?k????????????XY????Ti-3?y??y?u3?Q~???E??g?????f_I4??'>>>?$?&????e??G???0?1Go?@M??&?j??YJ3?zmhz??0<?Q??n???????i?
5w?0?1????O?5??SwM=?pm?????#f?>??q^g??j?J????}O?fi?xz&f?0?ǜ?^???yj???mm{?OM/B{z??%+??H??l4
I think that this is the plain PDF and that I can directly upload it to s3. Do I need to do something before uploading it?? Why it uploads only blank pages?
Thanks
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…