Writing XML Document to InputStream using dom4j

When tring to upload a XML file to AWS S3, I found that it’s not allowed to create a tmp file in server local, so I had to transfer the file as InputStream at first and upload it later.

This is the code of transfering the XML Document instance to InputStream and Byte array:

As dom4j is been used to generate the XML, some classes from which (e.g. Document, XMLWriter) can be found in the code.

Uploading files to AWS S3 By Java SpringBoot

This is a demo of uploading files to AWS S3 using Java SpringBoot.

First, we need to add the dependency of AWS S3:

Then add these configs in application.yml:

The accessKey, secretKey and bucket is nesscessary which can be found in aws’ admin dashboard. Continue reading