Added return to aborts

This commit is contained in:
Pünkösd Marcell 2021-08-09 15:52:45 +02:00
parent 01d7c76cff
commit 2b825985a1

View File

@ -26,16 +26,16 @@ class ObjectView(FlaskView):
try:
description = self.description_schema.loads(request.form.get('description'))
except ValidationError as e:
abort(400, str(e))
return abort(400, str(e))
# get and validate file
file = request.files['soundFile']
if file.content_type != 'audio/wave':
abort(400, f"{file.content_type} is not audio/wave")
return abort(400, f"{file.content_type} is not audio/wave")
if file.content_length <= 0:
abort(411, f"Content length for soundFile is not a positive integer or missing.")
return abort(411, f"Content length for soundFile is not a positive integer or missing.")
# create bucket if necessary
try:
@ -49,7 +49,7 @@ class ObjectView(FlaskView):
# check for conflict
if self._check_existance(description['tag']):
abort(409)
return abort(409)
# poot file into bucket
try:
@ -67,7 +67,7 @@ class ObjectView(FlaskView):
try:
data = storage.connection.get_object(current_app.config['MINIO_BUCKET_NAME'], tag)
except NoSuchKey:
abort(404)
return abort(404)
return Response(data.stream(), mimetype=data.headers['Content-type'])
@ -76,7 +76,7 @@ class ObjectView(FlaskView):
# TODO: Validate tag
if not self._check_existance(tag):
abort(404)
return abort(404)
storage.connection.remove_object(current_app.config['MINIO_BUCKET_NAME'], tag)