-
Notifications
You must be signed in to change notification settings - Fork 55
-
I tried to replace my codes using FLow<ByteArray>.toByteStream in my codes, but encountered error like this.
The Github actions stack: https://github.com/hantsy/aws-sdk-kotlin-spring-example/actions/runs/6939132384/job/18875971395?pr=6#step:6:79
The original code caused this issue:
suspend fun S3Client.store(bucketName: String, resourceKey: String, data: Flux<DataBuffer>) { this.createBucketIfNotExists(bucketName) val mediaType = MediaTypeFactory.getMediaType(resourceKey) .orElseGet { MediaType.APPLICATION_OCTET_STREAM } val byteArrayFlow = data .map { dataBuffer -> val bytes = ByteArray(dataBuffer.readableByteCount()) dataBuffer.read(bytes) DataBufferUtils.release(dataBuffer) bytes } .asFlow() val request = PutObjectRequest { bucket = bucketName body = byteArrayFlow.toByteStream(applicationScope) // here I use toByteStream to transfer the data type. key = resourceKey contentType = mediaType.toString() } val result = try { this.putObject(request) } catch (e: Exception) { throw S3ClientException(e.message ?: "Failed to store object $resourceKey") } println("store object to $bucketName: ${result.eTag}") }
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments
-
add to request checksumAlgorithm = ChecksumAlgorithm.Sha256
Beta Was this translation helpful? Give feedback.
All reactions
0 replies
-
It maybe still related to the Content Length header, in my case, we do not know uploaded file size.
Beta Was this translation helpful? Give feedback.
All reactions
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment