DEV Community

Play Button Pause Button

Posted on

Write a 10-minute Go app to serve video from a web page

This is a livecoding demo video I helped my friend/colleague JT produce for the company Town Hall that I put on every quarter. Basically, it shows - in golang - how to upload, download and serve video from our S3-compatible cloud storage platform.

you may obtain the sourcecode via

I spent a lot of time working out the timestamps for the various steps, because I myself really like to be able to jump to specific spots in a video, especially when I want to check that I haven't skipped a step. So if thats also helpful to you too, here they are:

0:00 Intro
0:30 Create your account
0:50 Make an API key (end-to-end encryption)
1:14 Make an access grant with Uplink tool
1:17 Set up the Uplink tool and set Access Grant name
1:32 Enter encryption passphrase
1:49 Make a bucket and name it
1:55 Share bucket with a Go program
2:07 Put the access grant into a Go program
2:17 Create "demo" folder with document called "main.go"
2:33 Define the access grant
2:45 Define a main method to handle basic bookkeeping
3:06 Parse the access grant
3:19 Open a project and make a small web interface to show files (listener MUX)
4:10 Hello World
4:20 Run go main.go to test the web serve is working
4:54 List the videos in the bucket (root endpoint)
5:32 List all the objects in bucket and make an iterator
6:04 Step through the iterator
6:38 Execute page template
7:04 Connect the HTML form element so files can be uploaded
7:10 Add upload target, add upload method
7:22 Stream data straight from the bucket into the Uplink Library via multipart reader
7:52 Loop though the mulitpart responses for the form element called "file"
8:14 Call UploadObject on the Uplink library
8:18 Pass the filename that was uploaded
8:25 Copy the data in and commit the object
8:37 RECAP: what we just wrote
8:56 Upload a sample file to the live network, to test the app
9:10 Serve the data via a serve endpoint
9:45 How to download
9:55 Get the context
10:00 Get the object
10:45 Run the code

I manage the technical community at Storj Labs/Tardigrade so naturally I also made a forum thread there, if you'd care to visit:

Discussion (3)

bffjossy profile image
bffjossy Author

Any feedback people have on whether this explains the topic well would be super helpful too. I wasnt sure how much background detail to include. On the one hand, it can be helpful. On the other hand if you are repeating the video, it could be redundant.

I felt like people understand buckets which are pretty pervasive. But Im wonder if the part about "access grant" clear enough for purposes of a speed tute?

walidhays profile image
Walid Haji

Not related to the topic, did you create the interface from a html template or from scratch?

bffjossy profile image
bffjossy Author

some of its cut and pasted, but it iirc was cut and pasted from scratch if that makes sense!