|
|
|
@ -24,16 +24,16 @@ class Storage(object): |
|
|
|
|
if self.storage: |
|
|
|
|
return self.storage.get_upload_token(filename, expires) |
|
|
|
|
|
|
|
|
|
def get_download_url(self, filename, expires=900, ftype=None, key=''): |
|
|
|
|
def get_download_url(self, filename, expires=900, ftype=None, key='',force_new=False): |
|
|
|
|
if self.storage: |
|
|
|
|
now = time.time() |
|
|
|
|
down_key = "_".join([key.lower(), CACHE_KEY_TEMPLATE.get('download_url_key'), filename]) |
|
|
|
|
download_val = cache.get(down_key) |
|
|
|
|
if download_val: |
|
|
|
|
if download_val and not force_new: |
|
|
|
|
if download_val.get("time") > now - 60: |
|
|
|
|
return download_val.get("download_url") |
|
|
|
|
|
|
|
|
|
download_url = self.storage.get_download_url(filename, expires, ftype) |
|
|
|
|
download_url = self.storage.get_download_url(filename, expires, ftype,force_new=False) |
|
|
|
|
cache.set(down_key, {"download_url": download_url, "time": now + expires}, expires) |
|
|
|
|
return download_url |
|
|
|
|
|
|
|
|
|