當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。