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


Python qiniu.put_file方法代码示例

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


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

示例1: save_file

# 需要导入模块: import qiniu [as 别名]
# 或者: from qiniu import put_file [as 别名]
def save_file(self, localfile, filename=None):

        # 构建鉴权对象
        auth = Auth(self._access_key, self._secret_key)
        # 上传到七牛后保存的文件名
        key = filename
        # 生成上传 Token,可以指定过期时间等
        token = auth.upload_token(self._bucket_name)
        ret, info = put_file(token, key, localfile)
        print(info)
        try:
            assert ret['key'] == key
            assert ret['hash'] == etag(localfile)
        except Exception as e:
            current_app.logger.info(e)
        return ret, info 
开发者ID:adisonhuang,项目名称:flask-blog,代码行数:18,代码来源:qiniustorage.py

示例2: upload

# 需要导入模块: import qiniu [as 别名]
# 或者: from qiniu import put_file [as 别名]
def upload(self, picture_path_list, link_only=False):
        if self.upload_handler:
            success_uploaded_list = []
            for picture_path in picture_path_list:
                picture_name = os.path.basename(picture_path)
                token = self.upload_handler.upload_token(self.container_name, picture_name, 3600)
                ret, info = put_file(token, picture_name, picture_path)
                bucket = BucketManager(self.upload_handler)
                success = bucket.stat(self.container_name, picture_name)
                print(success)
            self.write_markdown_picture_url(picture_path_list, link_only) 
开发者ID:kingname,项目名称:MarkdownPicPicker,代码行数:13,代码来源:QiniuUploader.py

示例3: upload_file_to_qiniu

# 需要导入模块: import qiniu [as 别名]
# 或者: from qiniu import put_file [as 别名]
def upload_file_to_qiniu(file_path, key=None, **kwargs):
    bucket_name = kwargs.pop('bucket_name', None)
    token = get_qiniu_token(key, bucket_name=bucket_name)
    ret, info = put_file(token, key, file_path, **kwargs)
    return ret, info 
开发者ID:gusibi,项目名称:momo,代码行数:7,代码来源:media.py

示例4: upload_file_to_qiniu

# 需要导入模块: import qiniu [as 别名]
# 或者: from qiniu import put_file [as 别名]
def upload_file_to_qiniu(file_path, file_name):
    print("[%s] uploading......" % file_name)
    token = q.upload_token(config['bucket_name'], file_name)
    ret, _ = put_file(token, file_name, file_path)
    assert ret['key'] == file_name
    assert ret['hash'] == etag(file_path)
    return os.path.join(config['bucket_url'], ret['key']) 
开发者ID:AloneMonkey,项目名称:OnlineIpaInstall,代码行数:9,代码来源:upload.py

示例5: down

# 需要导入模块: import qiniu [as 别名]
# 或者: from qiniu import put_file [as 别名]
def down(token, key, localfile, mime_type, delete=False):
    ret, info = qiniu.put_file(
                    token, key, localfile,
                    mime_type=mime_type,
                    check_crc=True
                )
    assert ret['key'] == key
    assert ret['hash'] == qiniu.etag(localfile)

    print(localfile)
    if delete:
        os.remove(localfile) 
开发者ID:billvsme,项目名称:videoSpider,代码行数:14,代码来源:upload_qiniu.py


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