Search code examples
javaclojurerackspace-cloudcloudfilesjclouds

How to enable CDN with JClouds and Rackspace via Clojure?


I'm attempting to use JCLouds via Clojure and would like to use the blobstore abstraction to create containers and then enable CDN serving on those containers. So far I haven't had much success.

I'm not a Java programmer so I'm not quite sure how to approach this, but it does appear there is a method that does what I need. That said, I'm unsure how to use that with org.jclouds.blobstore2.

What is the best way to achieve this in Clojure?


Solution

  • It turns out that via a Java example I was able to figure out the proper codepath for this in Clojure:

    (defn- enable-cdn [bs container]
      (->
        (blobstore/blobstore-context bs)
        .unwrap
        .getApi
        (.enableCDN container)))
    

    This will enable the CDN for a given container provided a valid blobstore instance. Maybe this will save someone else some time later.