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环境下。 if self.cdn_host: p = urlparse(self.cdn_host) scheme = p.scheme netloc = p.netloc return '{0}://{1}/{2}'.format(scheme, netloc, name.decode()) return self.bucket._make_url(self.bucket_name, name)
def __init__(self, endpoint, is_cname): p = urlparse(endpoint) self.scheme = p.scheme self.netloc = p.netloc self.is_cname = is_cname