Beispiel #1
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
Beispiel #2
0
 def image_processed_url(self, name):
     base_url, rule = self.options.get(
         'image_process_base_url'), self.options.get('image_process_rule')
     if base_url is None or not rule:
         raise ValueError('This file\'s thumb is not valuable.')
     return urljoin(base_url, name + rule)
Beispiel #3
0
 def url(self, name):
     base_url = self.options.get('base_url')
     if base_url is None:
         raise ValueError('This file is not accessible via a URL.')
     return urljoin(base_url, name)
Beispiel #4
0
 def image_processed_url(self, name):
     base_url, rule = self.options.get('image_process_base_url'), self.options.get('image_process_rule')
     if base_url is None or not rule:
         raise ValueError('This file\'s thumb is not valuable.')
     return urljoin(base_url, name + rule)
Beispiel #5
0
 def url(self, name):
     base_url = self.options.get('base_url')
     if base_url is None:
         raise ValueError('This file is not accessible via a URL.')
     return urljoin(base_url, name)