Django-compressor: how to write to S3, read from CloudFront?

前端 未结 6 1264
失恋的感觉
失恋的感觉 2020-12-12 19:52

I want to serve my compressed CSS/JS from CloudFront (they live on S3), but am unable to work out how to do it via the compressor settings in settings.py, I have the followi

6条回答
  •  独厮守ぢ
    2020-12-12 20:41

    Additionally, for streaming distributions it's useful to override the url function to allow rtmp:// urls, as in:

    import urlparse
    class VideoStorageForCloudFrontStreaming(S3BotoStorage):
        """
        Use when needing rtmp:// urls for a CloudFront Streaming distribution. Will return
        a proper CloudFront URL.
    
        Subclasses must be sure to set custom_domain.
        """
        def url(self, name):
            name = urlparse.quote(self._normalize_name(self._clean_name(name)))
            return "rtmp://%s/cfx/st/%s" % (self.custom_domain, name)
    
        # handy for JW Player:
        @Property
        def streamer(self):
            return "rtmp://%s/cfx/st" % (self.custom_domain)
    

提交回复
热议问题