def DELETE(self, req): """ Handles Abort Multipart Upload. """ upload_id = req.params['uploadId'] _check_upload_info(req, self.app, upload_id) # First check to see if this multi-part upload was already # completed. Look in the primary container, if the object exists, # then it was completed and we return an error here. container = req.container_name + '+segments' obj = '%s/%s' % (req.object_name, upload_id) req.get_response(self.app, container=container, obj=obj) # The completed object was not found so this # must be a multipart upload abort. # We must delete any uploaded segments for this UploadID and then # delete the object in the main container as well query = { 'format': 'json', 'prefix': '%s/%s/' % (req.object_name, upload_id), 'delimiter': '/', } resp = req.get_response(self.app, 'GET', container, '', query=query) # Iterate over the segment objects and delete them individually objects = loads(resp.body) for o in objects: container = req.container_name + '+segments' req.get_response(self.app, container=container, obj=o['name']) return HTTPNoContent()
def DELETE(self, req): # pylint: disable=invalid-name """ Handles DELETE Bucket tagging and DELETE Object tagging. """ # Send empty header to remove any previous value. if req.object_name: req.headers[OBJECT_TAGGING_HEADER] = "" else: req.headers[BUCKET_TAGGING_HEADER] = "" resp = req.get_versioned_response(self.app, 'POST', req.container_name, req.object_name) if resp.status_int == 202: headers = dict() if req.object_name: headers['x-amz-version-id'] = \ resp.sw_headers[VERSION_ID_HEADER] return HTTPNoContent(headers=headers) return resp
def DELETE(self, req): """ Handles Abort Multipart Upload. """ log_s3api_command(req, 'abort-multipart-upload') upload_id = req.params['uploadId'] _check_upload_info(req, self.app, upload_id) container = req.container_name + MULTIUPLOAD_SUFFIX # First check to see if this multi-part upload was already # completed. Look in the primary container, if the object exists, # then it was completed and we return an error here. obj = '%s/%s' % (req.object_name, upload_id) req.environ['oio.ephemeral_object'] = True try: req.get_response(self.app, container=container, obj=obj) finally: req.environ['oio.ephemeral_object'] = False # The completed object was not found so this # must be a multipart upload abort. # We must delete any uploaded segments for this UploadID and then # delete the object in the main container as well query = { 'format': 'json', 'prefix': '%s/%s/' % (req.object_name, upload_id), 'delimiter': '/', } # Force the master to be sure to fetch all uploaded parts req.environ.setdefault('oio.query', {}) req.environ['oio.query']['force_master'] = True resp = req.get_response(self.app, 'GET', container, '', query=query) # Iterate over the segment objects and delete them individually objects = json.loads(resp.body) for o in objects: container = req.container_name + MULTIUPLOAD_SUFFIX obj = o['name'].encode('utf-8') req.get_response(self.app, container=container, obj=obj) return HTTPNoContent()