PICGO配置七牛平台失败-getaddrinfo ENOTFOUND upload
报错内容
文件上传或者剪切板上传都是进度条变成红色,然后上传失败,查看报错日志如下:
2022-02-09 13:21:23 [PicGo INFO] Before transform
2022-02-09 13:21:23 [PicGo INFO] Transforming... Current transformer is [path]
2022-02-09 13:21:23 [PicGo INFO] Before upload
2022-02-09 13:21:23 [PicGo INFO] beforeUploadPlugins: renameFn running
2022-02-09 13:21:23 [PicGo INFO] Uploading... Current uploader is [qiniu]
2022-02-09 13:21:25 [PicGo WARN] failed
2022-02-09 13:21:25 [PicGo ERROR]
------Error Stack Begin------
RequestError: Error: getaddrinfo ENOTFOUND upload-
at new RequestError (D:\软件\Program Files\PicGo\resources\app.asar\node_modules\request-promise-core\lib\errors.js:14:15)
at Request.plumbing.callback (D:\软件\Program Files\PicGo\resources\app.asar\node_modules\request-promise-core\lib\plumbing.js:87:29)
at Request.RP$callback [as _callback] (D:\软件\Program Files\PicGo\resources\app.asar\node_modules\request-promise-core\lib\plumbing.js:46:31)
at self.callback (D:\软件\Program Files\PicGo\resources\app.asar\node_modules\request\request.js:185:22)
at Request.emit (node:events:394:28)
at Request.onRequestError (D:\软件\Program Files\PicGo\resources\app.asar\node_modules\request\request.js:877:8)
at ClientRequest.emit (node:events:394:28)
at Socket.socketErrorListener (node:_http_client:447:9)
at Socket.emit (node:events:394:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
-------Error Stack End-------
2022-02-09 13:21:25 [PicGo ERROR]
------Error Stack Begin------
RequestError: Error: getaddrinfo ENOTFOUND upload-
at new RequestError (D:\软件\Program Files\PicGo\resources\app.asar\node_modules\request-promise-core\lib\errors.js:14:15)
at Request.plumbing.callback (D:\软件\Program Files\PicGo\resources\app.asar\node_modules\request-promise-core\lib\plumbing.js:87:29)
at Request.RP$callback [as _callback] (D:\软件\Program Files\PicGo\resources\app.asar\node_modules\request-promise-core\lib\plumbing.js:46:31)
at self.callback (D:\软件\Program Files\PicGo\resources\app.asar\node_modules\request\request.js:185:22)
at Request.emit (node:events:394:28)
at Request.onRequestError (D:\软件\Program Files\PicGo\resources\app.asar\node_modules\request\request.js:877:8)
at ClientRequest.emit (node:events:394:28)
at Socket.socketErrorListener (node:_http_client:447:9)
at Socket.emit (node:events:394:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
-------Error Stack End-------
测试代码
在Github提了Issuse之后,作者给了如下测试代码。测试结果可以正常获取对象存储中的文件信息。
# -*- coding: utf-8 -*-
# RUN TIME: Python 3.6.5
# CREATION ON: 7/30, 2018
from qiniu import Auth, BucketManager
# 七牛相关配置
host = "rs.qbox.me"
key = "" # access key
secret = "" # secret key
q = Auth(key, secret)
bucket = BucketManager(q)
bucket_name = "" # 填你自己桶名称
def get_file_list():
bucket = BucketManager(q)
# 前缀
prefix = "" # 填写存储桶的目标文件夹
# 列举条目
limit = 1000
# 列举出除'/'的所有文件以及以'/'为分隔的所有前缀
delimiter = None
# 标记
marker = None
ret, eof, info = bucket.list(bucket_name, prefix, marker, limit, delimiter)
# print(info)
items: list = ret.get('items')
# 所有百分号(%25)都被转义为了百分号(%), 将 25 补充回去
keys = []
for item in items:
key = item.get('key')
idx = key.find('%')
if idx >= 0:
key = f'{key[:idx+1]}25{key[idx+1:]}'
keys.append(key)
# ['light/1%FQJR3aTUCkoUXwyNIAGg.jpg' ...]
print(keys)
if __name__ == '__main__':
get_file_list()
解决方法
最终测试发现是区域中前面的字母需要大写,我的是华南区域,看了其他教程和官方文档中的区域代码都是z2,最终在Picgo中修改为Z2后就可以正常上传了。