|
| 1 | +/* |
| 2 | + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | + |
| 6 | +package aws.sdk.kotlin.hll.s3transfermanager |
| 7 | + |
| 8 | +import aws.sdk.kotlin.services.s3.S3Client |
| 9 | +import aws.sdk.kotlin.services.s3.withConfig |
| 10 | + |
| 11 | +/** |
| 12 | + * High level utility for managing transfers to Amazon S3. |
| 13 | + */ |
| 14 | +public class S3TransferManager private constructor( |
| 15 | + public val client: S3Client, |
| 16 | + public val partSize: Long?, |
| 17 | + public val multipartUploadThreshold: Long?, |
| 18 | + public val multipartDownloadType: MultiPartDownloadType?, |
| 19 | + public val interceptors: MutableList<TransferInterceptor>?, |
| 20 | +) { |
| 21 | + public companion object { |
| 22 | + public operator fun invoke(block: Builder.() -> Unit): S3TransferManager = |
| 23 | + Builder().apply(block).build() |
| 24 | + } |
| 25 | + |
| 26 | + public class Builder { |
| 27 | + public var client: S3Client? = null |
| 28 | + public var partSize: Long? = 8_000_000L |
| 29 | + public var multipartUploadThreshold: Long? = 16_000_000L |
| 30 | + public var multipartDownloadType: MultiPartDownloadType? = Part |
| 31 | + public var interceptors: MutableList<TransferInterceptor>? = mutableListOf() |
| 32 | + |
| 33 | + internal fun build(): S3TransferManager = |
| 34 | + S3TransferManager( |
| 35 | + client = client?.withConfig { interceptors += BusinessMetricInterceptor } ?: error("client must be set"), |
| 36 | + partSize = partSize, |
| 37 | + multipartUploadThreshold = multipartUploadThreshold, |
| 38 | + multipartDownloadType = multipartDownloadType, |
| 39 | + interceptors = interceptors |
| 40 | + ) |
| 41 | + } |
| 42 | + |
| 43 | + public fun x(): String = "" // TODO |
| 44 | +} |
0 commit comments