12

I'm using the Cloud Files module which uses the Rackspace Cloud Files PHP API to store all uploaded files on Rackspace Cloud Files (a CDN). It all works very well.

However, today, Rackspace itself had an outage related to their API and it caused my entire site to break. I absolutely can't have this happen when my site is finally live. Is there any way to keep the files locally as well as in Cloud Files so that if there is a problem I can flip a setting in the admin pages and it'll start using the local files so that the site continues working while Rackspace works on the problem?

4
  • I am interested that you chose to use Cloud Files (Rackspace specific) and not the CDN module. Does the CDN module not have fallback? I am no pro on CDN.
    – Duncanmoo
    Commented Jul 11, 2012 at 21:46
  • 1
    I used the Cloud Files module because it handles actually transferring the files over to Rackspace, while the CDN module does not. CDN requires an external application called File Conveyor to do the transfers. I've had no end of problems getting File Conveyor to work with Cloud Files without breaking my site, so I went with the easier solution. Commented Jul 12, 2012 at 3:59
  • 2
    Maybe its a good ide to ask this as a feature request on the module's issue page. Theoretically if the Rackspace cloud have issues serving a file should return a "404" response. Then if that happens the module must fall back to the local file system. I think this can be done by the module developer.
    – ANDiTKO
    Commented Sep 5, 2012 at 7:41
  • The CDN module supports BOTH "File Conveyor" & "Origin Pull" modes. Origin pull is automatic, file conveyor is not. Rackspace cloud files only support file conveyor, thus the need for a specific module to automatically handle the transfer of files.
    – Mike
    Commented Sep 30, 2012 at 22:45

1 Answer 1

6

In javascript, you can listen to the image's onerror event listener.

set the source as normal. in onerror, set this.src to your local image path:

<img src="//somecdn.com/cat.jpg" onerror="this.src='/localpath/cat.jpg';" />​

you could use jquery to loop over all images on the page and add the onerror event listener

1
  • Not exactly what I was looking for, but a reasonable solution nonetheless. Commented May 13, 2013 at 23:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.