我们从Python开源项目中,提取了以下38个代码示例,用于说明如何使用django.utils.encoding.filepath_to_uri()。
def url(self, name): name = self._normalize_name(self._clean_name(name)) # name = filepath_to_uri(name) # ???????encode name = name.encode('utf8') # ????????????_make_url??urllib.quote????????unicode??????python2???? return self.bucket._make_url(self.bucket_name, name)
def url(self, name): if self.base_url is None: raise ValueError("This file is not accessible via a URL.") return urljoin(self.base_url, filepath_to_uri(name))
def url(self, name): if self.base_url is None: raise ValueError("This file is not accessible via a URL.") url = filepath_to_uri(name) if url is not None: url = url.lstrip('/') return urljoin(self.base_url, url)
def url(self, name): if self.conf.get('PUBLIC_URL') is None: raise ValueError("This file is not accessible via a URL.") return urljoin(self.conf.get('PUBLIC_URL'), filepath_to_uri(name))
def url(self, name): if MULTIDOMAIN_MEDIA: index = crc32(name.encode()) % len(MULTIDOMAIN_MEDIA) base_url = '%s%s/' % (MULTIDOMAIN_MEDIA[index], self.directory) return urljoin(base_url, filepath_to_uri(name)) else: return urljoin(self.base_url, filepath_to_uri(name))
def url(self, name, headers=None, response_headers=None, expire=None): return '{}{}'.format(settings.STATIC_URL,filepath_to_uri(name))
def url(self, name, headers=None, response_headers=None, expire=None): return '{}{}'.format(settings.MEDIA_URL, filepath_to_uri(name))
def url(self, name): return urljoin(self.base_url, filepath_to_uri(name))
def full_url(self, name): name = self._normalize_name(self._clean_name(name)) name = filepath_to_uri(name) full_url = urlparse.urljoin(settings.REMOTE_MEDIA_URL, name) log.info('>>> QiniuStorage full_url: %s'%name) return full_url
def url(self, name): name = self._normalize_name(self._clean_name(name)) name = filepath_to_uri(name) return '/%s'%name
def send_file(request, filepath, last_modified=None, filename=None): fullpath = filepath # Respect the If-Modified-Since header. statobj = os.stat(fullpath) if filename: mimetype, encoding = mimetypes.guess_type(filename) else: mimetype, encoding = mimetypes.guess_type(fullpath) mimetype = mimetype or 'application/octet-stream' if settings.USE_SENDFILE: response = django_sendfile_response(request, filepath) else: response = HttpResponse(open(fullpath, 'rb').read(), content_type=mimetype) if not last_modified: response["Last-Modified"] = http_date(statobj.st_mtime) else: if isinstance(last_modified, datetime): last_modified = float(dateformat.format(last_modified, 'U')) response["Last-Modified"] = http_date(epoch_seconds=last_modified) response["Content-Length"] = statobj.st_size if encoding: response["Content-Encoding"] = encoding if filename: filename_escaped = filepath_to_uri(filename) response["Content-Disposition"] = "attachment; filename=%s" % filename_escaped return response