AWS SDK または CLI で AbortMultipartUploads を使用する - Amazon Simple Storage Service

AWS SDK または CLI で AbortMultipartUploads を使用する

次のコード例は、AbortMultipartUploads を使用する方法を示しています。

.NET
AWS SDK for .NET
注記

GitHub には、その他のリソースもあります。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

using System; using System.Threading.Tasks; using Amazon.S3; using Amazon.S3.Transfer; /// <summary> /// This example shows how to use the Amazon Simple Storage Service /// (Amazon S3) to stop a multi-part upload process using the Amazon S3 /// TransferUtility. /// </summary> public class AbortMPU { public static async Task Main() { string bucketName = "doc-example-bucket"; // If the AWS Region defined for your default user is different // from the Region where your Amazon S3 bucket is located, // pass the Region name to the S3 client object's constructor. // For example: RegionEndpoint.USWest2. IAmazonS3 client = new AmazonS3Client(); await AbortMPUAsync(client, bucketName); } /// <summary> /// Cancels the multi-part copy process. /// </summary> /// <param name="client">The initialized client object used to create /// the TransferUtility object.</param> /// <param name="bucketName">The name of the S3 bucket where the /// multi-part copy operation is in progress.</param> public static async Task AbortMPUAsync(IAmazonS3 client, string bucketName) { try { var transferUtility = new TransferUtility(client); // Cancel all in-progress uploads initiated before the specified date. await transferUtility.AbortMultipartUploadsAsync( bucketName, DateTime.Now.AddDays(-7)); } catch (AmazonS3Exception e) { Console.WriteLine($"Error: {e.Message}"); } } }
  • API の詳細については、「AWS SDK for .NET API リファレンス」の「AbortMultipartUploads」を参照してください。

AWS SDK デベロッパーガイドとコード例の完全なリストについては、「このサービスを AWS SDK で使用する」を参照してください。このトピックには、使用開始方法に関する情報と、以前の SDK バージョンの詳細も含まれています。