Utilizzo PutBucketAccelerateConfiguration con un AWS SDK o una CLI - Amazon Simple Storage Service

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 PutBucketAccelerateConfiguration con un AWS SDK o una CLI

I seguenti esempi di codice mostrano come utilizzarePutBucketAccelerateConfiguration.

.NET
AWS SDK for .NET
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.

using System; using System.Threading.Tasks; using Amazon.S3; using Amazon.S3.Model; /// <summary> /// Amazon Simple Storage Service (Amazon S3) Transfer Acceleration is a /// bucket-level feature that enables you to perform faster data transfers /// to Amazon S3. This example shows how to configure Transfer /// Acceleration. /// </summary> public class TransferAcceleration { /// <summary> /// The main method initializes the client object and sets the /// Amazon Simple Storage Service (Amazon S3) bucket name before /// calling EnableAccelerationAsync. /// </summary> public static async Task Main() { var s3Client = new AmazonS3Client(); const string bucketName = "doc-example-bucket"; await EnableAccelerationAsync(s3Client, bucketName); } /// <summary> /// This method sets the configuration to enable transfer acceleration /// for the bucket referred to in the bucketName parameter. /// </summary> /// <param name="client">An Amazon S3 client used to enable the /// acceleration on an Amazon S3 bucket.</param> /// <param name="bucketName">The name of the Amazon S3 bucket for which the /// method will be enabling acceleration.</param> private static async Task EnableAccelerationAsync(AmazonS3Client client, string bucketName) { try { var putRequest = new PutBucketAccelerateConfigurationRequest { BucketName = bucketName, AccelerateConfiguration = new AccelerateConfiguration { Status = BucketAccelerateStatus.Enabled, }, }; await client.PutBucketAccelerateConfigurationAsync(putRequest); var getRequest = new GetBucketAccelerateConfigurationRequest { BucketName = bucketName, }; var response = await client.GetBucketAccelerateConfigurationAsync(getRequest); Console.WriteLine($"Acceleration state = '{response.Status}' "); } catch (AmazonS3Exception ex) { Console.WriteLine($"Error occurred. Message:'{ex.Message}' when setting transfer acceleration"); } } }
CLI
AWS CLI

Per impostare la configurazione di accelerazione di un bucket

L'put-bucket-accelerate-configurationesempio seguente abilita la configurazione di accelerazione per il bucket specificato.

aws s3api put-bucket-accelerate-configuration \ --bucket my-bucket \ --accelerate-configuration Status=Enabled

Questo comando non produce alcun output.

PowerShell
Strumenti per PowerShell

Esempio 1: questo comando abilita l'accelerazione di trasferimento per il bucket S3 specificato.

$statusVal = New-Object Amazon.S3.BucketAccelerateStatus('Enabled') Write-S3BucketAccelerateConfiguration -BucketName 's3testbucket' -AccelerateConfiguration_Status $statusVal

Per un elenco completo delle guide per sviluppatori AWS SDK e degli esempi di codice, consulta. Utilizzo di questo servizio con un SDK AWS Questo argomento include anche informazioni su come iniziare e dettagli sulle versioni precedenti dell'SDK.