sas_usage.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:blobfs 作者: mbartoli 项目源码 文件源码
def container_sas(self):        
        container_name = self._create_container()
        self.service.create_blob_from_text(container_name, 'blob1', b'hello world')

        # Access only to the blobs in the given container
        # Read permissions to access blobs
        # Expires in an hour
        token = self.service.generate_container_shared_access_signature(
            container_name,
            ContainerPermissions.READ,
            datetime.utcnow() + timedelta(hours=1),
        )

        # Create a service and use the SAS
        sas_service = BlockBlobService(
            account_name=self.account.account_name,
            sas_token=token,
        )

        blob = sas_service.get_blob_to_text(container_name, 'blob1')
        content = blob.content # hello world

        self.service.delete_container(container_name)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号