選取您的 Cookie 偏好設定

我們使用提供自身網站和服務所需的基本 Cookie 和類似工具。我們使用效能 Cookie 收集匿名統計資料,以便了解客戶如何使用我們的網站並進行改進。基本 Cookie 無法停用,但可以按一下「自訂」或「拒絕」以拒絕效能 Cookie。

如果您同意,AWS 與經核准的第三方也會使用 Cookie 提供實用的網站功能、記住您的偏好設定,並顯示相關內容,包括相關廣告。若要接受或拒絕所有非必要 Cookie,請按一下「接受」或「拒絕」。若要進行更詳細的選擇,請按一下「自訂」。

GetBucketReplication 搭配 AWS SDK 或 CLI 使用 - AWS SDK 程式碼範例

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

GetBucketReplication 搭配 AWS SDK 或 CLI 使用

下列程式碼範例示範如何使用 GetBucketReplication

CLI
AWS CLI

下列命令會擷取名為 之儲存貯體的複寫組態amzn-s3-demo-bucket

aws s3api get-bucket-replication --bucket amzn-s3-demo-bucket

輸出:

{ "ReplicationConfiguration": { "Rules": [ { "Status": "Enabled", "Prefix": "", "Destination": { "Bucket": "arn:aws:s3:::amzn-s3-demo-bucket-backup", "StorageClass": "STANDARD" }, "ID": "ZmUwNzE4ZmQ4tMjVhOS00MTlkLOGI4NDkzZTIWJjNTUtYTA1" } ], "Role": "arn:aws:iam::123456789012:role/s3-replication-role" } }
Java
SDK for Java 2.x
注意

GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫中設定和執行。

/** * Retrieves the replication details for the specified S3 bucket. * * @param s3Client the S3 client used to interact with the S3 service * @param sourceBucketName the name of the S3 bucket to retrieve the replication details for * * @throws S3Exception if there is an error retrieving the replication details */ public static void getReplicationDetails(S3Client s3Client, String sourceBucketName) { GetBucketReplicationRequest getRequest = GetBucketReplicationRequest.builder() .bucket(sourceBucketName) .build(); try { ReplicationConfiguration replicationConfig = s3Client.getBucketReplication(getRequest).replicationConfiguration(); ReplicationRule rule = replicationConfig.rules().get(0); System.out.println("Retrieved destination bucket: " + rule.destination().bucket()); System.out.println("Retrieved priority: " + rule.priority()); System.out.println("Retrieved source-bucket replication rule status: " + rule.status()); } catch (S3Exception e) { System.err.println("Failed to retrieve replication details: " + e.awsErrorDetails().errorMessage()); } }
PowerShell
Tools for PowerShell

範例 1:傳回名為 'mybucket' 的儲存貯體上設定的複寫組態資訊。

Get-S3BucketReplication -BucketName amzn-s3-demo-bucket
  • 如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考中的 GetBucketReplication

AWS CLI

下列命令會擷取名為 之儲存貯體的複寫組態amzn-s3-demo-bucket

aws s3api get-bucket-replication --bucket amzn-s3-demo-bucket

輸出:

{ "ReplicationConfiguration": { "Rules": [ { "Status": "Enabled", "Prefix": "", "Destination": { "Bucket": "arn:aws:s3:::amzn-s3-demo-bucket-backup", "StorageClass": "STANDARD" }, "ID": "ZmUwNzE4ZmQ4tMjVhOS00MTlkLOGI4NDkzZTIWJjNTUtYTA1" } ], "Role": "arn:aws:iam::123456789012:role/s3-replication-role" } }
隱私權網站條款Cookie 偏好設定
© 2025, Amazon Web Services, Inc.或其附屬公司。保留所有權利。