Sono disponibili altri esempi AWS SDK nel repository AWS Doc SDK
Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.
Utilizzo GetBucketLocation
con un AWS SDK o una CLI
I seguenti esempi di codice mostrano come utilizzareGetBucketLocation
.
- CLI
-
- AWS CLI
-
Il comando seguente recupera il vincolo di posizione per un bucket denominato
my-bucket
, se esiste un vincolo:aws s3api get-bucket-location --bucket my-bucket
Output:
{ "LocationConstraint": "us-west-2" }
-
Per i dettagli sull'API, consulta Command Reference. GetBucketLocation
AWS CLI
-
- PowerShell
-
- Strumenti per PowerShell
-
Esempio 1: questo comando restituisce il vincolo di posizione per il bucket 's3testbucket', se esiste un vincolo.
Get-S3BucketLocation -BucketName 's3testbucket'
Output:
Value ----- ap-south-1
-
Per i dettagli sull'API, vedere in Cmdlet Reference. GetBucketLocationAWS Tools for PowerShell
-
- Rust
-
- SDK per Rust
-
Nota
C'è altro su. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS
. async fn show_buckets(strict: bool, client: &Client, region: &str) -> Result<(), Error> { let resp = client.list_buckets().send().await?; let buckets = resp.buckets(); let num_buckets = buckets.len(); let mut in_region = 0; for bucket in buckets { if strict { let r = client .get_bucket_location() .bucket(bucket.name().unwrap_or_default()) .send() .await?; if r.location_constraint().unwrap().as_ref() == region { println!("{}", bucket.name().unwrap_or_default()); in_region += 1; } } else { println!("{}", bucket.name().unwrap_or_default()); } } println!(); if strict { println!( "Found {} buckets in the {} region out of a total of {} buckets.", in_region, region, num_buckets ); } else { println!("Found {} buckets in all regions.", num_buckets); } Ok(()) }
-
Per i dettagli sulle API, consulta la GetBucketLocation
guida di riferimento all'API AWS SDK for Rust.
-