In our flask API, we have an endpoint for uploading a document. This endpoint receives the uploaded document, does some checks and uploads this document to MinIO. We want to stream the received document directly to the remote storage without actually processing it via the API.
One idea is to do the following:
@app.route('/upload', methods=['POST'])
def upload():
upload_url = get_presigned_upload_url()
response = requests.put(url=upload_url, files={'file': request.stream})
I can see two problems in the above code:
1- How can I make sure that the stream consists of only one file
2- How can I extract the mimetype from the actual file, without just trusting the file extension