Skip to content

Commit

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

app.logger.debug(tid + "The request content type is: " + request.content_type)
app.logger.debug(tid + "The request contains the following headers: " + str(list(request.headers.keys())))
app.logger.debug(tid + "The request contains the following args: " + str(list(request.args.keys())))
app.logger.debug(tid + "The request contains the following files: " + str(list(request.files.keys())))
Expand All @@ -128,14 +129,17 @@ 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 a filestream")
abort(400, 'Please provide a valid \'file\' attachment in RDF\\XML format.')
if 'file' in request.files:
app.logger.info(tid + "Read RDF\\XML from file content")
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 a filestream")
abort(400, 'Please provide a valid \'file\' attachment in RDF\\XML format.')
else:
app.logger.info(tid + "Read RDF\\XML from body stream")
file_stream = request.stream
file_name = vocabulary_name+".rdf"

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

Expand Down

0 comments on commit c66881b

Please sign in to comment.