diff --git a/moto/s3/models.py b/moto/s3/models.py index 0abc3e4c2..a97e28627 100644 --- a/moto/s3/models.py +++ b/moto/s3/models.py @@ -164,6 +164,10 @@ class S3Backend(BaseBackend): return self.set_key(bucket_name, multipart.key_name, value) + def cancel_multipart(self, bucket_name, multipart_id): + bucket = self.buckets[bucket_name] + del bucket.multiparts[multipart_id] + def list_multipart(self, bucket_name, multipart_id): bucket = self.buckets[bucket_name] return bucket.multiparts[multipart_id].list_parts() diff --git a/moto/s3/responses.py b/moto/s3/responses.py index ded07e2f0..b2ff1b60b 100644 --- a/moto/s3/responses.py +++ b/moto/s3/responses.py @@ -188,6 +188,10 @@ def _key_response(request, full_url, headers): else: return 404, headers, "" elif method == 'DELETE': + if 'uploadId' in query: + upload_id = query['uploadId'][0] + s3_backend.cancel_multipart(bucket_name, upload_id) + return 204, headers, "" removed_key = s3_backend.delete_key(bucket_name, key_name) template = Template(S3_DELETE_OBJECT_SUCCESS) return 204, headers, template.render(bucket=removed_key)