Drupal - Serve static files via S3

I ended up using the S3AutoPush module. I migrated it to Drupal 7 and hacked the hell out of it to make it fit my needs.

If anyone reads this and is interested, I'd be happy to share my code. I won't put it on drupal.org for now since it's a real hack-job and not worthy yet.


Other Drupal 7 modules like the File API do this. However I have more experience with the Amazon S3 module.

The Drupal 7 AmazonS3 module still doesn't handle JS/CSS. There is a patch for this, however it's status for the past year has been set to "Needs work", because of the following response by Andrew Berry:

I see a few issues with this patch as-is: 1. It's possible to have two file records for the same file, under different paths. For example, public://bucket/image.jpg and s3://bucket/image.jpg. For managed files, this could lead to data corruption. 2. We had to patch quite a few modules for the S3 wrapper to work properly, since it requires a bucket in the URL. I imagine a ton of modules hardcode public:// file paths without normalizing the URL. 3. There's a performance issue in that S3 can be very slow to create new assets and do an initial stat. For image styles, we basically replaced the style generation with our own code, which is a pain to do for CSS and JS. And, we could have very similar problems with contrib modules.

Anyways, if we can address all of these I'd be interested in getting this in. However, I'm guessing to do this it a way that doesn't break all the things will have to wait for D8.

Speaking of Drupal 8, there is an s3 module by @cweagans that already handles aggregated CSS/JS files as well: https://www.drupal.org/project/flysystem_s3 Hopefully this will be helpful to someone.

Tags:

Files

7