Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Get an Amazon S3 object from a Multi-Region Access Point by using an AWS SDK - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Get an Amazon S3 object from a Multi-Region Access Point by using an AWS SDK

The following code example shows how to get an object from a Multi-Region Access Point.

Kotlin
SDK for Kotlin
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

Configure the S3 client to use the Asymmetric Sigv4 (Sigv4a) signing algorithm.

suspend fun createS3Client(): S3Client { // Configure your S3Client to use the Asymmetric Sigv4 (Sigv4a) signing algorithm. val sigV4AScheme = SigV4AsymmetricAuthScheme(CrtAwsSigner) val s3 = S3Client.fromEnvironment { authSchemes = listOf(sigV4AScheme) } return s3 }

Use the Multi-Region Access Point ARN instead of a bucket name to retrieve the object.

suspend fun getObjectFromMrap( s3: S3Client, mrapArn: String, keyName: String, ): String? { val request = GetObjectRequest { bucket = mrapArn // Use the ARN instead of the bucket name for object operations. key = keyName } var stringObj: String? = null s3.getObject(request) { resp -> stringObj = resp.body?.decodeToString() if (stringObj != null) { println("Successfully read $keyName from $mrapArn") } } return stringObj }
SDK for Kotlin
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

Configure the S3 client to use the Asymmetric Sigv4 (Sigv4a) signing algorithm.

suspend fun createS3Client(): S3Client { // Configure your S3Client to use the Asymmetric Sigv4 (Sigv4a) signing algorithm. val sigV4AScheme = SigV4AsymmetricAuthScheme(CrtAwsSigner) val s3 = S3Client.fromEnvironment { authSchemes = listOf(sigV4AScheme) } return s3 }

Use the Multi-Region Access Point ARN instead of a bucket name to retrieve the object.

suspend fun getObjectFromMrap( s3: S3Client, mrapArn: String, keyName: String, ): String? { val request = GetObjectRequest { bucket = mrapArn // Use the ARN instead of the bucket name for object operations. key = keyName } var stringObj: String? = null s3.getObject(request) { resp -> stringObj = resp.body?.decodeToString() if (stringObj != null) { println("Successfully read $keyName from $mrapArn") } } return stringObj }
PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.