def cdn_url(request): """ A context processor to expose the full cdn url in templates. """ cloudfiles_storage = CloudFilesStorage() container_url = cloudfiles_storage._get_container_url() cdn_url = container_url + CUMULUS.get('STATIC_PREFIX', '') return {'CDN_URL': cdn_url}
def cdn_url(request): """ A context processor to expose the full cdn url in templates. """ cloudfiles_storage = CloudFilesStorage() static_url = settings.STATIC_URL container_url = cloudfiles_storage._get_container_url() cdn_url = container_url + static_url return {'CDN_URL': cdn_url}
def __init__(self, settings, callback, error_callback, parent_logger=None): Transporter.__init__(self, settings, callback, error_callback, parent_logger) # Raise exception when required settings have not been configured. configured_settings = Set(self.settings.keys()) if not "username" in configured_settings: raise ImpropertlyConfigured, "username not set" if not "api_key" in configured_settings: raise ImpropertlyConfigured, "api_key not set" if not "container" in configured_settings: raise ImpropertlyConfigured, "container not set" # Map the settings to the format expected by S3Storage. try: self.storage = CloudFilesStorage(self.settings["username"], self.settings["api_key"], self.settings["container"]) except Exception, e: if e.__class__ == cloudfiles.errors.AuthenticationFailed: raise ConnectionError, "Authentication failed" else: raise ConnectionError(e)
from django.db import models from imagekit.models import ImageModel from cumulus.storage import CloudFilesStorage cfstorage = CloudFilesStorage() class Photo(ImageModel): title = models.CharField(max_length=50) image = models.ImageField(upload_to='photos') ik_image = models.ImageField(storage=cfstorage, upload_to='photos') def __unicode__(self): return self.title class IKOptions: spec_module = 'photos.specs' cache_dir = 'photos' image_field = 'ik_image'
from django.db import models from cumulus.storage import CloudFilesStorage cloudfiles_storage = CloudFilesStorage() class Thing(models.Model): "A dummy model to use for tests." image = models.ImageField(storage=cloudfiles_storage, upload_to='cumulus-tests') document = models.FileField(storage=cloudfiles_storage, upload_to='cumulus-tests') custom = models.FileField(storage=cloudfiles_storage, upload_to='cumulus-tests')