Pilih preferensi cookie Anda

Kami menggunakan cookie penting serta alat serupa yang diperlukan untuk menyediakan situs dan layanan. Kami menggunakan cookie performa untuk mengumpulkan statistik anonim sehingga kami dapat memahami cara pelanggan menggunakan situs dan melakukan perbaikan. Cookie penting tidak dapat dinonaktifkan, tetapi Anda dapat mengklik “Kustom” atau “Tolak” untuk menolak cookie performa.

Jika Anda setuju, AWS dan pihak ketiga yang disetujui juga akan menggunakan cookie untuk menyediakan fitur situs yang berguna, mengingat preferensi Anda, dan menampilkan konten yang relevan, termasuk iklan yang relevan. Untuk menerima atau menolak semua cookie yang tidak penting, klik “Terima” atau “Tolak”. Untuk membuat pilihan yang lebih detail, klik “Kustomisasi”.

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

Mode fokus
Get an Amazon S3 object from a Multi-Region Access Point by using an AWS SDK - Amazon Simple Storage Service
Halaman ini belum diterjemahkan ke dalam bahasa Anda. Minta terjemahan

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(DefaultAwsSigner) 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(DefaultAwsSigner) 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 }

For a complete list of AWS SDK developer guides and code examples, see Developing with Amazon S3 using the AWS SDKs. This topic also includes information about getting started and details about previous SDK versions.

PrivasiSyarat situsPreferensi cookie
© 2025, Amazon Web Services, Inc. atau afiliasinya. Semua hak dilindungi undang-undang.