Reputation: 5366
I've a requirement to generate file's (.docx , .pdf) using docx4j and iText. And end generated documents should be store at S3 bucket using AWS lambda function.
I've tried couple of options but none of the solution works for me. I can able to upload a local file to S3 bucket and write a normal text file to AWS S3 bucket using my java code.
However my require is, firstly I've to create a file path's for (.docx, .pdf) of the desire location i.e. S3 bucket then give a call to my code to generate the files(.docx, .pdf) and save it to S3 bucket.
NOTE: I wish to call my save method (lambda handler) which will directly save files in S3 bucket. Or either way if s3 doesn't allow to save files directly then whats the alternative aws provide to save files locally/temp so later i can push those temp files into s3 bucket??
If any ever work on this or have an idea how to do that please share their inputs.
Upvotes: 0
Views: 4223
Reputation: 4480
There are two ways you can do this. First method would be storing the file in /tmp/
first then use the putobject API to upload to s3 specifying the bucket and keyname.
Second method is directly uploading the object to s3 using the same putobject but specifying your object.
The docs for this can be found here
A detailed example of this can be found here
Upvotes: 1