Skip to main content

Drupal CORS File Module

Tags

Drupal logo

Over the last year or so the Drupal projects I have been involved with at work have required the need to work with a lot of video files being maintained in Drupal.  Well, as you can imagine the larger the files we are maintaining the greater the strain this puts on our host to serve the files.  To try and account for this we moved as many of the assets in Drupal as we could off to a Rackspace Cloud Files account so they could be served from a cloud delivery network.  This worked well, except that we cannot really expect a client to upload assets in Rackspace and then add URLs to Drupal.  We needed a way for Drupal to talk to our Rackspace container without the client even knowing it was happening and we needed the client webpage to write the files directly to Rackspace, not through Drupal first and then to Rackspace.  So how were we going to achieve this?  Well, we first looked for Drupal contributed modules, and when we struck out there we knew we were going to have to create our own module from the ground up, and that is just what we did.  The CORS_File project became a public repository on Trekk's GitHub page that allows Drupal admins to setup file fields that communicate directly with Rackspace.  All creating, editing, updating, and deleting of a file are done just as they normally would be in Drupal, but the file is stored and served from Rackspace alleviating the strain from your Drupal host.  Better yet, all communication from Drupal to Rackspace is done directly from the client web page by setting CORS headers on the Rackspace container and using Ajax to communicated with the container.  The file is not written to Drupal first and then uploaded to Rackspace, all communication is direct to Rackspace and then the necessary data is then written back to Drupal.

I have provided complete documentation for the module along with prerequisites and installation instructions on the repository's README.md file.  PULL requests and community help are welcome!  

https://github.com/TrekkDesign/CORS_File https://github.com/TrekkDesign/CORS_File

Logo reference from Drupal.org

Member for

3 years 9 months
Matt Eaton

Long time mobile team lead with a love for network engineering, security, IoT, oss, writing, wireless, and mobile.  Avid runner and determined health nut living in the greater Chicagoland area.