Skip to content
Advertisement

Save text pdf direct to s3 without having to save it locally

I am generating pdf files using itext 5 and Java, and saving them locally then saving these local saved files on AWS S3. Is there a way to just send them straight to S3 without having to save them locally. I have seen a few examples but none is working for me.

This is how am generating the pdf file

JavaScript

This is how I save it on s3

JavaScript

String pathLocal is the path where am saving the file locally, while String pathAws is the path on S3 where the file is saved.

Advertisement

Answer

So I found out a way, I converted the itext file to a byte array and uploaded the pdf file as a byte array

JavaScript

When uploading it to S3 I passed the bytes instead of the file path as I was doing before

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement