删除桶之前,必须先删除桶下的所有文件和分片上传产生的碎片。
要删除分片上传产生的碎片,首先使用Bucket.ListMultipartUploads列举出所有碎片,然后使用Bucket.AbortMultipartUpload删除这些碎片。
以下代码用于删除桶:
let deletebucketreq = AWSS3DeleteBucketRequest.init() deletebucketreq?.bucket = S3BucketName s3.deleteBucket(deletebucketreq!).continueWith(block: { (task:AWSTask) -> Any? in if let error = task.error { print("delete bucket failed with error: (\(error))") } else { print("delete bucket completed.") } return nil }) |