Python进行,七牛多文件压缩(mkzip) 返回结果为 404,Document not found

Python进行,七牛多文件压缩(mkzip)  返回结果为 404,Document not found

用Python进行七牛多文件处理(mkzip),一直报404的错,索引文件没有问题,可以访问,索引文件内的图片地址也是可以访问的,不知道是哪个文件找不到
参考的七牛相关文档:
https://developer.qiniu.com/k...
https://developer.qiniu.com/d...

from qiniu import Auth, PersistentFop, urlsafe_base64_encode

access_key = '....'

secret_key = '....'

q = Auth(access_key, secret_key)

bucket = 'hera'

key = 'mkzip-index_2.txt'

fops = 'mkzip/4/'

saveas_key = urlsafe_base64_encode(bucket + ':' + "xlz_mkzip4.zip")

fops = fops+'|saveas/'+saveas_key

pfop = PersistentFop(q, bucket)

ops = []

ops.append(fops)

ret, info = pfop.execute(key, ops, 1)

print("ret: ", ret)

print("info: ", info)

assert ret['persistentId'] is not None

打印结果

ret:    None

info: _ResponseInfo__response:<Response [404]>, exception:None, status_code:404, text_body:{"error":"Document not found"}, req_id:wpUAAABWbvpfniQW, x_log:X-Log, error:Document not found

索引文件:
https://heras.igengmei.com/mk...

索引文件内容生成过程:

from qiniu import urlsafe_base64_encode

images = ["https://heras.igengmei.com/2020/07/23/0fcd8a243b", "https://heras.igengmei.com/2020/07/23/e8f134ef12", "https://heras.igengmei.com/2020/07/24/d9d4f234a5"]

for i in images:

print('/url/' + urlsafe_base64_encode(i))

生成结果:

/url/aHR0cHM6Ly9oZXJhcy5pZ2VuZ21laS5jb20vMjAyMC8wNy8yMy8wZmNkOGEyNDNi

/url/aHR0cHM6Ly9oZXJhcy5pZ2VuZ21laS5jb20vMjAyMC8wNy8yMy9lOGYxMzRlZjEy

/url/aHR0cHM6Ly9oZXJhcy5pZ2VuZ21laS5jb20vMjAyMC8wNy8yNC9kOWQ0ZjIzNGE1

确定空间名没有问题,
尝试加管道也没用


回答:

任务的id提供下呢,或者试下这个demo

# -*- coding: utf-8 -*-

# flake8: noqa

#DOCUMENT https://developer.qiniu.com/dora/manual/1667/mkzip#2

from qiniu import Auth,http, urlsafe_base64_encode

access_key = 'YOUR_ACCESS_KEY'

secret_key = 'YOUR_SECRECT_KEY'

q = Auth(access_key, secret_key)

url = 'http://api.qiniu.com/pfop/'

fops = "mkzip/4"

saveas_key = urlsafe_base64_encode('bucket_name:save.zip') # 转码后的空间:文件名

fops = fops + '|saveas/' + saveas_key

body = { "fops": fops, 'bucket': 'bucket_name', 'key': 'index.txt'} # 索引文件所在空间及索引文件名

ret, info = http._post_with_auth(url=url, data=body, auth=q)

print(info)

assert ret['persistentId']

以上是 Python进行,七牛多文件压缩(mkzip) 返回结果为 404,Document not found 的全部内容, 来源链接: utcz.com/a/162540.html

回到顶部