Menu

Uploading straight from the browser to DigitalOcean Spaces
📰

Uploading straight from the browser to DigitalOcean Spaces

DEV Community: flask·Remdore·about 4 hours ago
#Bz4q6Uww
#devtoflask#devto#dev#spaces#upload
Reading 0:00
15s threshold

Spaces Gallery is a small Flask app I maintain that uploads images to DigitalOcean Spaces and shows them in a gallery. Right now every upload goes through the app. The browser sends the file to Flask, Flask checks it, makes a thumbnail and writes both to Spaces.

The usual advice is to skip that middle step. The app hands the browser a presigned POST, a short-lived signed form, and the browser sends the file straight to Spaces. I built that into the gallery and measured what it changes, using the app's own code and deployment setup.

The setup

The app ran under gunicorn exactly as its Procfile starts it, which means one sync worker, on a 1 GB Droplet in Frankfurt. The Spaces bucket was in Frankfurt too. My laptop played the browser, uploading noise PNGs of 1, 4 and 8 MB that can't be compressed. On the Droplet, a sampler recorded the app's CPU time, memory and network traffic four times a second.

The direct path has three steps:

The page asks the app for a presigned POST.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.