File upload to Google Cloud Storage using a Flask API
Part 1/3 — Setting up filedepot & different work environments
This is the first part of our little post series where we explore how to build a Flask JSON API for uploading files to Google Cloud Storage. Today we are going to deal with some requirements, descisions, and setting up our basic app.
This is going to be a rather extensive tutorial. If you want to dive into the code along with reading: it’s available on Github.
Recently at work, I wanted to add a simple file upload to one of our Flask APIs. It took me a while to figure out how to do it. It seems like in addition to some special requirements we had, the available packages lack some easy to understand documentation. That’s why I want to share some insights on how you can integrate file uploading into your Python app.
So, this was our list of requirements to be covered:
- Upload files to Google Cloud Storage
- Customize the directory structure of the uploaded files and their names
- Upload an image, store the original version and two resized versions
- The solution should be easy to extend to allow uploading other file types than images (e.g. pdf, audio files)