This commit is contained in:
parent
dfa848b1d8
commit
7ef991912c
@ -5,6 +5,7 @@ from minio.error import BucketAlreadyExists, BucketAlreadyOwnedByYou, ResponseEr
|
|||||||
from marshmallow import ValidationError
|
from marshmallow import ValidationError
|
||||||
from utils import storage
|
from utils import storage
|
||||||
from schemas import DescriptionSchema
|
from schemas import DescriptionSchema
|
||||||
|
import opentracing
|
||||||
|
|
||||||
|
|
||||||
class ObjectView(FlaskView):
|
class ObjectView(FlaskView):
|
||||||
@ -23,6 +24,7 @@ class ObjectView(FlaskView):
|
|||||||
|
|
||||||
def post(self):
|
def post(self):
|
||||||
# get important data from the request
|
# get important data from the request
|
||||||
|
with opentracing.tracer.start_active_span('parseAndValidate'):
|
||||||
try:
|
try:
|
||||||
description = self.description_schema.loads(request.form.get('description'))
|
description = self.description_schema.loads(request.form.get('description'))
|
||||||
except ValidationError as e:
|
except ValidationError as e:
|
||||||
@ -37,6 +39,7 @@ class ObjectView(FlaskView):
|
|||||||
if file.content_length <= 0:
|
if file.content_length <= 0:
|
||||||
return 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.")
|
||||||
|
|
||||||
|
with opentracing.tracer.start_active_span('ensureBuckets'):
|
||||||
# create bucket if necessary
|
# create bucket if necessary
|
||||||
try:
|
try:
|
||||||
storage.connection.make_bucket(current_app.config['MINIO_BUCKET_NAME'])
|
storage.connection.make_bucket(current_app.config['MINIO_BUCKET_NAME'])
|
||||||
@ -47,10 +50,19 @@ class ObjectView(FlaskView):
|
|||||||
pass
|
pass
|
||||||
# Everything else should be raised
|
# Everything else should be raised
|
||||||
|
|
||||||
|
with opentracing.tracer.start_active_span('checkExistence'):
|
||||||
# check for conflict
|
# check for conflict
|
||||||
if self._check_existance(description['tag']):
|
if self._check_existance(description['tag']):
|
||||||
return abort(409)
|
return abort(409)
|
||||||
|
|
||||||
|
with opentracing.tracer.start_active_span(
|
||||||
|
'minio.putObject',
|
||||||
|
tags={
|
||||||
|
"bucket": current_app.config['MINIO_BUCKET_NAME'],
|
||||||
|
"object_name": description['tag'],
|
||||||
|
"length": file.content_length
|
||||||
|
}
|
||||||
|
):
|
||||||
# poot file into bucket
|
# poot file into bucket
|
||||||
try:
|
try:
|
||||||
storage.connection.put_object(current_app.config['MINIO_BUCKET_NAME'], description['tag'], file,
|
storage.connection.put_object(current_app.config['MINIO_BUCKET_NAME'], description['tag'], file,
|
||||||
|
Loading…
Reference in New Issue
Block a user