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

谢林臻
  • 1
新手上路,请多包涵

用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

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

回复
阅读 646
1 个回答

任务的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']
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
你知道吗?

宣传栏