manager.py 文件源码

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

项目:ucloud-storage-python-wrapper 作者: wishket 项目源码 文件源码
def put_object_to_container(self, container_name,
                              file_path=None,
                              file_name=None,
                              file_stream=None):
        """
        upload file to target container
        :param container_name:
            target container_name - string
            required=True
        :param file_path: file's path for upload - string
        :param file_name: file's name for get urls - string
        :param file_stream: file's data string - string
        :return: submit response
        """

        # make file object to comfortable for uploading
        if not file_name:
            file_name = file_path.split('/')[-1]

        url = self.url + '/' + container_name + '/' + file_name

        if not file_stream:
            file_stream = open(file_path, 'rb').read()

        response = requests.put(
            url,
            data=file_stream,
            headers=self.base_headers
        )

        return response
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号