Using external Media and Downloads in WordPress with Linode Object Storage

After successfully experimenting with a Linode Nanode for a jitsi server I needed a new project. I chose to give Linode Object Storage a try and integrated it for external media and downloads with a download manager plugin in WordPress.

Linode Object Storage

Object Storage is a flat rate of 5$ per month and includes 250 GB. Inbound data transfer isn’t counted and 1 TB of outbound traffic is included (additional GB are 0.01$).

Setting up Object Storage in Linode Manager is remarkably easy. Basically you just add a bucket, give it a name and chose a region for the data center to be used. Of course I used Frankfurt to keep all data in Germany. On the second page you can easily generate access keys.
The bucket names in a cluster (region) are unique. Objects have got an individual URL in the format bucket.cluster/filename.ext.

Creating a bucket is as easy as naming it and choosing the location.

I use ForkLift as my transfer client of choice and it’s super easy to add Linode’s Object Storage as an AWS S3 connection. The buckets then appear as folders.

Buckets appear as folders in ForkLift.

Per default every object is private, but permissions can be changed easily. To make objects publicly accessible, the read permission for “Others” needs to be set. On other clients this might be called “Everyone”.

Signed URLs

Signed URLs can be created to grant time limited access to a private object by utilising a designated access key. This just appends a key to the objects URL in the format of ?AWSAccessKeyId=YOUROBJECTSTORAGEACCESSKEY&Expires=1.

These cannot be generated in Linode Manager, sadly. The CLIs of Linode and s3cmd can be used. I didn’t get lucky to get the Linode CLI to install/work properly, but since there was an alternative I didn’t bother more than two seconds. Installing s3cmd with homebrew was easy and generating a key by following Linode’s instructions worked.
I don’t have a use case for this at the moment, but it’s nice to try it and to know I could utilise signed URLs if I ever need them.

WordPress

Basic integration

I used integration in the title, but that’s maybe too big of a word. Since every file is available with a URL, you just point your media towards it.

That’s basically it. To test all of this, I made a Super Secret Test Page and added some media. Everything works as expected with the integrated image and video blocks.

Useful Download links

I also wanted to offer download links with a preferably nice download button. This caused some frustration because using the integrated “Button” block causes e. g. images to be opened inside the browser.
The “File” block can’t be used because it only works with local files.

I tried several download manager plugins: WordPress Download Manager, Simple Download Manager, Download Monitor, Easy Media Download, Download Attachments. The only one that is simple enough for what I want and where the download links actually work as expected is Download Monitor by Never5.

Download Monitor has several style options, which can be altered with custom templates. It also counts and logs downloads, but importantly can be configured to anonymise IP addresses, which I of course configured immediately. I don’t care who you are. That’s none of my business.

For now, I use the built-in “Button” template. I like this one because it shows additional information: file name, a counter, and most importantly the file size. The button scales nicely to the post width, even on mobile devices.