当前位置: 首页>>代码示例>>Python>>正文


Python encoding.filepath_to_uri方法代码示例

本文整理汇总了Python中django.utils.encoding.filepath_to_uri方法的典型用法代码示例。如果您正苦于以下问题:Python encoding.filepath_to_uri方法的具体用法?Python encoding.filepath_to_uri怎么用?Python encoding.filepath_to_uri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.utils.encoding的用法示例。


在下文中一共展示了encoding.filepath_to_uri方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: url

# 需要导入模块: from django.utils import encoding [as 别名]
# 或者: from django.utils.encoding import filepath_to_uri [as 别名]
def url(self, name, parameters=None, expire=None, http_method=None):
        # Preserve the trailing slash after normalizing the path.
        name = self._normalize_name(self._clean_name(name))
        if expire is None:
            expire = self.querystring_expire

        if self.custom_domain:
            url = "{}//{}/{}".format(
                self.url_protocol, self.custom_domain, filepath_to_uri(name))

            if self.querystring_auth and self.cloudfront_signer:
                expiration = datetime.utcnow() + timedelta(seconds=expire)

                return self.cloudfront_signer.generate_presigned_url(url, date_less_than=expiration)

            return url

        params = parameters.copy() if parameters else {}
        params['Bucket'] = self.bucket.name
        params['Key'] = name
        url = self.bucket.meta.client.generate_presigned_url('get_object', Params=params,
                                                             ExpiresIn=expire, HttpMethod=http_method)
        if self.querystring_auth:
            return url
        return self._strip_signing_parameters(url) 
开发者ID:jschneier,项目名称:django-storages,代码行数:27,代码来源:s3boto3.py

示例2: url

# 需要导入模块: from django.utils import encoding [as 别名]
# 或者: from django.utils.encoding import filepath_to_uri [as 别名]
def url(self, name, expire=None):
        name = self._get_valid_path(name)

        if expire is None:
            expire = self.expiration_secs

        make_blob_url_kwargs = {}
        if expire:
            sas_token = self.custom_service.generate_blob_shared_access_signature(
                self.azure_container, name, permission=BlobPermissions.READ, expiry=self._expire_at(expire))
            make_blob_url_kwargs['sas_token'] = sas_token

        return self.custom_service.make_blob_url(
            container_name=self.azure_container,
            blob_name=filepath_to_uri(name),
            protocol=self.azure_protocol,
            **make_blob_url_kwargs) 
开发者ID:jschneier,项目名称:django-storages,代码行数:19,代码来源:azure_storage.py

示例3: url

# 需要导入模块: from django.utils import encoding [as 别名]
# 或者: from django.utils.encoding import filepath_to_uri [as 别名]
def url(self, name):
        if self.base_url is None:
            raise ValueError("This file is not accessible via a URL.")
        gridfs, filename = self._get_gridfs(name)
        try:
            file_oid = gridfs.get_last_version(filename=name).__getattr__('_id')
        except NoFile:
            # In case not found by filename
            try:
                # Check is a valid ObjectId
                file_oid = ObjectId(name)
            except (InvalidId, TypeError, ValueError):
                return None
            # Check if exist a file with that ObjectId
            if not gridfs.exists(file_oid):
                return None
        return urljoin(self.base_url, filepath_to_uri(str(file_oid))) 
开发者ID:nesdis,项目名称:djongo,代码行数:19,代码来源:storage.py

示例4: url

# 需要导入模块: from django.utils import encoding [as 别名]
# 或者: from django.utils.encoding import filepath_to_uri [as 别名]
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)) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:6,代码来源:storage.py

示例5: url

# 需要导入模块: from django.utils import encoding [as 别名]
# 或者: from django.utils.encoding import filepath_to_uri [as 别名]
def url(self, name):
        name = self._normalize_name(self._clean_name(name))
        name = filepath_to_uri(name)
        protocol = u'https://' if self.secure_url else u'http://'
        return urljoin(protocol + self.bucket_domain, name) 
开发者ID:glasslion,项目名称:django-qiniu-storage,代码行数:7,代码来源:backends.py

示例6: get_thumbnail_url

# 需要导入模块: from django.utils import encoding [as 别名]
# 或者: from django.utils.encoding import filepath_to_uri [as 别名]
def get_thumbnail_url(self):
        """
        Returns the (absolute) URL for the image's thumbnail version.
        """
        return urljoin(settings.MEDIA_URL, filepath_to_uri(self.get_thumbnail_path())) 
开发者ID:fausecteam,项目名称:ctf-gameserver,代码行数:7,代码来源:fields.py

示例7: url

# 需要导入模块: from django.utils import encoding [as 别名]
# 或者: from django.utils.encoding import filepath_to_uri [as 别名]
def url(self, name, parameters=None, expire=None):
        url = super().url(name, parameters, expire)

        if hasattr(settings, 'AWS_PRIVATE_CUSTOM_DOMAIN'):
            # Django storage doesn't handle custom domains with auth strings
            custom_domain = settings.AWS_PRIVATE_CUSTOM_DOMAIN
            parts = list(parse.urlsplit(url))
            parts[1:3] = custom_domain, filepath_to_uri(name)
            return parse.urlunsplit(parts)

        return url 
开发者ID:OpenTechFund,项目名称:hypha,代码行数:13,代码来源:storage_backends.py

示例8: url

# 需要导入模块: from django.utils import encoding [as 别名]
# 或者: from django.utils.encoding import filepath_to_uri [as 别名]
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) 
开发者ID:neon-jungle,项目名称:wagtailvideos,代码行数:9,代码来源:storage.py

示例9: url

# 需要导入模块: from django.utils import encoding [as 别名]
# 或者: from django.utils.encoding import filepath_to_uri [as 别名]
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) 
开发者ID:xiewenya,项目名称:django-aliyun-oss2-storage,代码行数:8,代码来源:backends.py


注:本文中的django.utils.encoding.filepath_to_uri方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。