I suddenly started seeing this warning message being logged, even though there were no changes in the usage of or on the underlying aws libs. I've been using aws-java-sdk version 1.6.9.1
No content length specified for stream data. Stream contents will be buffered in memory and could result in out of memory errors.
This is howthe file is uploaded:
client.putObject(bucketName, key, new ByteArrayInputStream(data), new ObjectMetadata())
I suspect I may be seeing this because I'm not setting the content length on the ObjectMetadata object, but that's how it was before and no warning was being generated.
Anyone has any insight as to why this warning message would suddenly start appearing?
Thanks!
I know this has been a while but I just had to deal with this today and found this explanation in the docs.
When uploading files, the AWS S3 Java client will attempt to determine the correct content type if one hasn't been set yet. Users are responsible for ensuring a suitable content type is set when uploading streams. If no content type is provided and cannot be determined by the filename, the default content type, "application/octet-stream", will be used.
For more information on the Content-Type header, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17
In my case I had to buffer the stream so I used something like this (from this reference).
ByteBuffer buffer = new ByteBuffer(...)
...
ObjectMetadata meta = new ObjectMetadata();
meta.setContentLength(buffer.limit());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With