Skip to content

Commit

Permalink
Increased debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
g-nardiello committed Mar 14, 2024
1 parent aef40a5 commit 724fe6b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ def upload_file() -> UploadFileResponse:
tid = date.strftime('[%s] ')
app.logger.info(tid + "Requested file upload")

app.logger.debug(tid + "The request contains the following headers: ", request.headers.keys())
app.logger.debug(tid + "The request contains the following args: ", request.args.keys())
app.logger.debug(tid + "The request contains the following files: ", request.files.keys())

# Authenticate using the provided token
provided_secret = request.headers.get('Authorization')
if not provided_secret or provided_secret != f"Bearer {endpoint_secret}":
Expand All @@ -124,10 +128,13 @@ def upload_file() -> UploadFileResponse:
abort(400, 'Please provide \'repo_full_name\' query parameter.')

# Receive the file from the client as a stream
if 'file' not in request.files:
app.logger.error(tid + "Aborted 400 - \'file\' attachment not found")
abort(400, 'Please provide the RDF\\XML attachment into \'file\' form field.')
file_stream = request.files['file'].stream
file_name = request.files['file'].filename
if not file_stream:
app.logger.error(tid + "Aborted 400 - \'file\' attachment not found")
app.logger.error(tid + "Aborted 400 - \'file\' attachment not a filestream")
abort(400, 'Please provide a valid \'file\' attachment in RDF\\XML format.')

app.logger.info(tid + f"{file_name} will be pushed into {repo_full_name} for vocabulary {vocabulary_name}")
Expand Down

0 comments on commit 724fe6b

Please sign in to comment.