def url(self, name):
     if ENABLED:
         file_path = filepath_to_uri(name)
         hextime = "%08x" % time.time()
         token = hashlib.md5(self.secret_key + '/' + file_path + hextime).hexdigest()
         return urlparse.urljoin(self.base_url, '/'.join((token, hextime, file_path)))
     else:
         return super(self.__class__, self).url(name)
示例#2
0
 def url(self, path):
     """
     Return an absolute URL where the file's contents can be accessed
     directly by a Web browser.
     """
     url = filepath_to_uri(path)
     if url is not None:
         url = url.lstrip('/')
     url = urljoin(self.base_url, url)
     if self.url_as_download and self.isfile(path):
         url += '?action=download'
     return url
示例#3
0
 def FileSystemStorage_url(self, name):
     if self.base_url is None:
         raise ValueError("This file is not accessible via a URL.")
     return urlparse.urljoin('/uploads', storage.filepath_to_uri(name))