I am successfully storing objects to S3. As a result of PutObjectRequest it returns PutObjectResult, which has a getMetadata() method. However, the metadata it returns is holding some values and misses others that I would expect to be there. In particular it misses the content length value, though it is explicitly assigned to PutObjectRequest.
For instance, this sample code:
val client: AmazonS3 = ???
val contentBytes = "Test content".getBytes
val inputStream: InputStream = new ByteArrayInputStream(contentBytes)
val metadata = new ObjectMetadata
metadata.setContentLength(contentBytes.length)
val putRequest = new PutObjectRequest("bucketName", "key", inputStream, metadata)
.withStorageClass(StorageClass.valueOf("ReducedRedundancy"))
val putObjectResult = client.putObject(putRequest)
println(s"Storage class: ${putObjectResult.getMetadata.getStorageClass}; Length: ${putObjectResult.getMetadata.getContentLength}")
would return the following: Storage class: REDUCED_REDUNDANCY; Length: 0
Is it a bug, am I doing something wrong, or is it expected behaviour?