I am trying to get a simple image upload app working on Heroku using Flask. I’m following the tutorial here: http://flask.pocoo.org/docs/patterns/fileuploads/
However, I want to use S3 to store the file instead of a temporary directory, since Heroku does not let you write to disk. I cannot find any examples of how to do this specifically for Heroku and Flask.
It seems to me that in the example code that stores the uploaded file to a temporary file, you would just replace
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))with code that uploads the file to S3 instead.For example, from the linked page:
Or if you want to upload to S3 asynchrnously, you could use whatever queuing mechanism is provided by Heroku.