Amazon.S3.AmazonS3Client.DeleteObjects C# (CSharp) Method

DeleteObjects() public method

This operation enables you to delete multiple objects from a bucket using a single HTTP request. You may specify up to 1000 keys.
public DeleteObjects ( DeleteObjectsRequest request ) : Amazon.S3.Model.DeleteObjectsResponse
request Amazon.S3.Model.DeleteObjectsRequest Container for the necessary parameters to execute the DeleteObjects service method.
return Amazon.S3.Model.DeleteObjectsResponse
        public DeleteObjectsResponse DeleteObjects(DeleteObjectsRequest request)
        {
            var marshaller = new DeleteObjectsRequestMarshaller();
            var unmarshaller = DeleteObjectsResponseUnmarshaller.Instance;

            return Invoke<DeleteObjectsRequest,DeleteObjectsResponse>(request, marshaller, unmarshaller);
        }

Usage Example

Example #1
0
        /// <summary>AWS S3 여러 객체 삭제</summary>
        public DeleteObjectsResponse DeleteObjectList(List<string> pKeyList)
        {
            try
            {
                using (AmazonS3Client client = new AmazonS3Client())
                {
                    DeleteObjectsRequest multiObjectDeleteRequest = new DeleteObjectsRequest();
                    multiObjectDeleteRequest.BucketName = strAwsBucketName;

                    foreach (string key in pKeyList)
                    {
                        multiObjectDeleteRequest.AddKey(key);
                    }

                    DeleteObjectsResponse response = client.DeleteObjects(multiObjectDeleteRequest);

                    //response.DeleteErrors.Count = 실패한 삭제 객체
                    //response.DeletedObjects.Count = 성공한 삭제 객체
                    //.Key, .Code, .Message로 정보 확인 가능.
                    return response;
                }
            }
            catch (AmazonS3Exception amazonS3Exception)
            {
                throw amazonS3Exception;
            }
        }
All Usage Examples Of Amazon.S3.AmazonS3Client::DeleteObjects
AmazonS3Client