4๐
โ
I ended up writing a storage backend. The settings.CUSTOM_DOMAIN
is the address of the CDN. My backend code is as follows โ
class CustomGoogleCloudStorage(GoogleCloudStorage):
custom_domain = settings.CUSTOM_DOMAIN
def make_url(self, name):
host = "https://" + self.custom_domain
return urllib.parse.urljoin(host, name)
def url(self, name):
name = self._normalize_name(name)
url = self.make_url(name)
key_name, base64_key = get_storage_key()
expiration_time = datetime.datetime.utcnow() + datetime.timedelta(hours=1) #put your desired time here
return sign_url(url, key_name, base64_key, expiration_time)
The sign_url
function is taken from GCPโs github.
๐คalamshafi2263
2๐
Django is a high-level Python Web framework. You might use the Cryptographic signing feature used by Django with the signed URLs Python (Programmatically creating signed URLs) described in Cloud CDN documentation. Take a look on both links and let us know if that helps to answer your inquiry.
๐คuser10880591
- [Django]-Ajax: post array of integers to Django
- [Django]-Python chained comparison
- [Django]-'ReverseManyToOneDescriptor' object has no attribute 'all'
Source:stackexchange.com