jeudi 18 mars 2021

Is there a better way than to cast user input on the backend of my Flask application?

I am running a python Flask app on Heroku and trying to write a new function that takes user input from a textarea then upload to AMS s3 as a plain text document. The application should have a function that retrieves the file and show it to the user.

After some reading on the boto3 docs I found that the upload_to_s3 (or similarly named) functions would take file like objects. I am not aware how JS could handle files on the frontend so the only way I could think of is:

  1. grab the user input with request.form.get()
  2. cast into a bytearray and create a tmp file by calling mktemp in python
  3. upload the file to s3 and then delete the tmp file

However I’m aware that this is stupid way as it would be not scalable with handling these files at the backend.

Is there a frontend/JS way to do it?




Aucun commentaire:

Enregistrer un commentaire