Even Simple Bugs Costs Time

I truly hope this will help someone but I am actually writing to help myself.

after the second time this has happened, and wasted hours of my life I am I will find this post on google just before banging my head against the wall blacks me out.

it is silly, stupid and so minor it happened to me twice!

base 64 encoding exhausts a stream

val streamMD5 = new String(Base64.encode(resultByte))

will exhaust a stream (since it is reading it, very reasonable actually)

so passing that mutable stream around will obviously cause error since it will seem empty or dataLength=0.

and will make amazon fire:

Data read has a different length than the expected data=0

the solution is to reset the stream after working with it.

stream.reset()
val putRequest = s3client.putObject(new PutObjectRequest(bucketName, keyName, stream, meta))
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.