Non-local Files on Drupal 6

Drupal 6 does not handle non-local files well. That means if you want to use something like Amazon's S3 file service you are pretty much out of luck. Media Mover got around this by overriding some templates but the implementation did not work well for extensibility and left most use cases in the dark. Ultimately the problem with Drupal 6 is that core and contributed modules leave system level file functions in templates with no alter functions. Not having file load or file alter functions makes it almost impossible to override things without rewriting these templates. This is really not good but since Drupal 7 mostly solves this problem we can probably forgive ourselves.

Simple CDN with Media Mover and S3

Updated 10/26/09: added improved url rewriting rules

So you want an easy to setup CDN that does not require much work and integrates with Drupal. Here is a quick setup to get to serve assets automatically from your Drupal files directory from S3

What you need:

  • Drupal site
  • Media Mover
  • S3 account

Get started
Install Media Mover, enable the S3, Directory, and AutoRun modules on your admin/build/modules page. Go to admin/settings/media_mover and enter your S3 credentials.

Media Mover

S3 without PEAR

I just ran across this which looks like I can potentially cleanup one of the annoying issues that the S3 implementation that Media Mover uses.

Currently, when Media Mover goes to push a file to S3, it has to run the full file through memory, demanding a much higher memory overhead each time you want to move a file. This can mean going above 100mbs for PHP which is not exactly possible on shared hosts.

I'm going to try some implementation with it and see how things go. Hopefully this will significantly improve S3 performance.