Member of The Internet Defense League
Donald L. Merand

My Own Personal Embed Server

I’ve stopped hosting this site on my own webserver, and moved to Github’s Pages using Jekyll, and I couldn’t be happier. I don’t have to worry about the 1KB/month in bandwidth of people reading the site, load times are fast, and deployment is dead simple. I love the static site concept, and am very grateful to Github for being magnanimous enough to host all of us hacker types’ personal web pages using their totally rad system.

I do have one problem though: what if I want to host big files, or media files, the kind that you don’t exactly want in a git repository? For example, entire albums of mp3s or a bunch of images? Naturally, I could use one of the zillion “cloud” providers of file storage (eg. Dropbox, Photobucket, Imgur, Soundcloud, etc.), and indeed I do use Flickr to host my photos. But in general, I don’t trust/don’t want to pay for cloud providers, and I also want a little bit more control over how/where my files are being stored.

The simplest thing to do would be this: upload files to my existing webserver by hand, put them in custom folders, and link to those files using manual URLs when I’m writing blog posts. But I write programs for a living, I can do something better than that! Right in the middle of writing a post, I want to be able to quickly upload a file to my webserver, and get the URL for that file back, paste that URL into my blog post and continue right on writing. Low friction - it’s the only kind of friction I can handle when I’m working. When things get in my way I have a bad habit of moving on to something more fun or (worse) avoiding the difficult/boring thing completely.

So I Wrote It…

I figure that all I need are two things:

  1. A web-side script which can take files via POST, put them into folders, and return the URL of the file on the server.
  2. A client-side script which I can use to pass files to my webscript.

… So I wrote it. I wrote it in PHP, which is still the easiest for droppin’ on webservers and having it just work. I posted the code right here, so go and clone it!

Usage

Notes

Related Posts