Meteor-Files: Failed to load PDF document from AWS
I’m having an issue:
I am using PDFKit(A JavaScript PDF generation library for Node and the browser)
PDF document created successfully and also upload on AWS successfully but when i am trying to opne the document the document not loading and showing message “Failed to load document”.
My Code is:
let details = Async.runSync(function (done) {
doc = new PDFDocument({size: 'A4', margin: 50});
doc.info.Title = 'Study Report';
doc.info.Author = '';
doc.fontSize(18);
doc.font('Times-Roman')
.text(title,{align: 'center',height:100}).moveDown(1.0);
doc.fontSize(12);
doc.text(content,{align: 'justify'}).moveDown(2.0);
doc.fontSize(12);
doc.text(signature,{align: 'right'});
//doc.text('PDFKit is simple', 10, 30, {align: 'justify', width: 200});
let path = process.env["PWD"] +`/.meteor/local/files/report-${title}.pdf`;
doc.pipe(fs.createWriteStream(path));
done(null, path);
doc.end();
});
if(details.result){
otps = {
fileName: `${title}`,
type: 'application/pdf',
}
Files.addFile(details.result, otps,function(error, fileRef) {
if(!error){
//Meteor.users.update({_id:userId},{$set:{'paymentDetails.invoicePathId':fileRef._id}});
Meteor.call('manageStudyReport',fileRef._id,studyInstanceUid,function(error,response){
if(error) {
console.log('Error',error);
}
});
}
//return true;
}, true);
}
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 17 (8 by maintainers)
File was uploading to AWS:S3 but there was no contents.
Right now I resolved my problem and your codes working properly.
Thank you very much for support.