I create PDF docs in memory as OutputStream
s. These should be uploaded to S3. My problem is that it's not possible to create a PutObjectRequest
from an OutputStream
directly (according to this thread in the AWS dev forum). I use aws-java-sdk-s3
v1.10.8 in a Dropwizard app.
The two workarounds I can see so far are:
- Copy the
OutputStream
to anInputStream
and accept that twice the amount of RAM is used. - Pipe the
OutputStream
to anInputStream
and accept the overhead of an extra thread (see this answer)
If i don't find a better solution I'll go with #1, because it looks as if I could afford the extra memory more easily than threads/CPU in my setup.
Is there any other, possibly more efficient way to achive this that I have overlooked so far?
Edit:
My OutputStream
s are ByteArrayOutputStream
s
OutputStream
does not store data (possibly except forByteArrayOutputStream
, but then you'd say you created it in memory as a byte array) – Parenteau