0

The POI PowerPoint api has a method write(outputstream).

But I see S3Client has an api which only accepts an InputStream to upload files: putObject(bucket, fileKey, inputStream, objectMetadata)

Could someone please suggest the best way to upload the PowerPoint file to s3?

  1. Should I temporarily write on the disk using the powerpointApi.write(FileOutputStream) and then upload this file to S3 using the putObject(bucket, fileKey, file) or putObject(bucket, fileKey, inputStream)?

  2. Or should I write the PowerPoint to OutputStream using powerpointApi.write(FileOutputStream) and then convert the output stream to input stream using this accepted answer on stackoverflow (How to upload a Java OutputStream to AWS S3) and then write to s3 using putObject(bucket, fileKey, inputStream)?

Also could someone please explain the pros and cons of both these approaches?

Also if someone has better solution please help.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Mukesh
  • 13
  • 5
  • 2
    It is your decision and nothing which can be discussed here since this is not a discussion forum. If I could using temporary files, then I would do this. But this will not always be possible. And if not, then a byte array in memory filled using `ByteArrayOutputStream` and then reread using `ByteArrayInputStream` would be the solution. – Axel Richter Oct 06 '18 at 05:53
  • https://blog.ostermiller.org/convert-java-outputstream-inputstream – PJ Fanning Oct 06 '18 at 12:25

0 Answers0