External Storage

The platform provides storage by default on it's own infrastructure, through a combination of a private data centre and Amazon S3. It possible however, to configure The Platform to use your own infrastructure for media storage and delivery.

If you choose to completely host your media yourself, you have the choice to set this up using the External Storage settings found under Settings > External Storage in The Platform. If you cannot find it, it probably means it has been disabled for your account. Contact New Spark support for a resolution.

In this interface you can setup a new storage profile.

Amazon S3

If you would like to use your own Amazon S3 account instead of News Spark's, you can do this here. You need to specify an S3 Access key, your secret key and a (pre-created) bucket.

The basePath is used to prefix all the file names. While you can specify your own basePath, the only basePath that is actually compatible with New Spark is '/storage/'. So unless you have a special purpose for the external storage system, be sure to always use /storage/ here.

FTP

If you choose FTP, you must also make sure you are able to serve the media using HTTP. So in this case, you'll need at least a web server with scripting support, as well as an FTP server. For SFTP, you will need an SSH server.

After creation, the following information is requested (all of which is required).


Field Description
Hostname The domain name of your FTP or SSH server.
TCP port Usually this is 21 for FTP or 22 SFTP, but if your server is running on a different port, change it here.
Username The username to access your server.
Password The password for the account.
Base path If the files need to be in a sub-directory, you can enter it here. If you pre-ceed the base path with a /, it will be relative to the root of your server, otherwise it will be relative to the login directory.
Directory structure See below.


Directory Structure

If flat is chosen for a directory structure, all files will be thrown into one directory. While this is fine for a small amount of files, if you plan to exceed more than a few hundred files it is highly recommended to choose hash2. The hash2 structure ensures that your file system stays very fast. The only reason you would not want to use it is if you use a btree-based filesystem, which is very uncommon as of 2010.

The hash2 uses the ID of the file to get an md5 hash. (for example fcea920f7412b5da7be0cf42b8c93759 for file id 1234567). The first 8 characters are then used to generate a 4-level deep directory name. In the example of 1234567, we would store the file in a directory named fc/ea/92/0f. The ensures that no more than 256 subdirectories are created in every directory.

Now, if we assume that 1234567 was a jpeg, the following files will be created:


fc/ea/92/0f/1234567_11.jpg
fc/ea/92/0f/1234567_12.jpg
fc/ea/92/0f/1234567_13.jpg
fc/ea/92/0f/1234567_14.jpg
fc/ea/92/0f/1234567_15.jpg


Serving the files

The problem with serving media files, is that the URLs used for accessing the files are completely different from the URLs used to store the files. For this reason you are forced to host a script that maps the urls to their respective paths.

The urls expected by the media serving system look like the following:


media.example.org/storage/1234567/11
media.example.org/storage/1234567/12
media.example.org/storage/1234567/13
media.example.org/storage/1234567/14
media.example.org/storage/1234567/15


As you can see, it is also missing the extension, which requires you to actually do a directory scan to find the appropriate file.

We have provided a PHP script that does all these things, and it's freely downloadable:

extstorage.zip(v0.2)

Last steps

Configure Transcoder Profiles:

If you've verified your settings are entered correctly, you can now change the External Storage location for each of the transcoder profiles in your Platform project. The list of profiles can be found under Settings > Media Transcoder. This will make the transcoders send the files to your infrastructure. Note that you can send files to multiple locations.

Configure Storage domain name:

Enter your storage domain name in the Storage domain field under Settings > Project Settings.

Be advised that any previously uploaded files to a different storage profile will now no longer be accessible. It is therefore wise to have everything setup before your project starts.

0 comments

Be the first to comment on External Storage.

Add a Comment

  • captcha