-
Notifications
You must be signed in to change notification settings - Fork 55
Description
Describe the bug
I am using putObject to upload small files (< 5Mb) to S3 bucket:
putObject {
bucket = credentials.bucketName
key = "$path/$fileName"
metadata = metadataVal
body = path.toFile().asByteStream()
}
some files are uploaded without any issues for others I get 503 error:
<Error>
<Code>XMinioBackendDown</Code>
<Message>Object storage backend is unreachable</Message>
<Key>wire-cells-android/test_image_1.png</Key>
<BucketName>io</BucketName>
<Resource>/io/wire-cells-android/test_image_1.png</Resource>
<RequestId>181F882CC38AD42D</RequestId>
<HostId>f2096f02-5516-4920-8eff-0ae12239852a</HostId>
</Error>
Observation 1:
putObject {
bucket = credentials.bucketName
key = "$path/$fileName"
metadata = metadataVal
body = ByteStream.fromBytes(path.toFile().readBytes())
}
If I am reading file in memory before sending and construct ByteBuffer from ByteArray it works for all files without any issues:
Observation 2:
putObject {
bucket = credentials.bucketName
key = "$cellName/$fileName"
metadata = metadataVal
body = path.toFile().readBytes().inputStream().asByteStream()
}
If I am reading file in memory but create ByteBuffer via inputStream I get same errors again:
Observation 3:
I created a custom ProgressListener wrapping stream content to support upload progress indication.
For successfully uploaded files progress listener was reporting the amount of bytes sent equal to the file size.
For files that could not be uploaded putObject operation tried to send more than the file size.
Regression Issue
- Select this option if this issue appears to be a regression.
Expected behavior
putObject operation with stream body should work consistently for all files
putObject {
bucket = credentials.bucketName
key = "$path/$fileName"
metadata = metadataVal
body = path.toFile().asByteStream()
}
Current behavior
putObject operation with stream body fails to upload some files.
Steps to Reproduce
with(s3Client) {
putObject {
bucket = credentials.bucketName
key = "$cellName/$fileName"
metadata = metadataVal
body = path.toFile().asByteStream()
}
}
Possible Solution
No response
Context
No response
AWS SDK for Kotlin version
1.3.112
Platform (JVM/JS/Native)
Jvm
Operating system and version
Android