PICGO配置七牛平台失败-getaddrinfo ENOTFOUND upload

本文记录了一位用户在使用PicGo图片上传工具时遇到的配置七牛云存储失败的问题。错误信息显示为getaddrinfo ENOTFOUND upload,经过排查发现是区域代码填写不正确,解决方案是将区域代码由小写改为大写,如华南区域的z2应改为Z2。修改后,图片上传功能恢复正常。
摘要由CSDN通过智能技术生成

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后就可以正常上传了。

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Biscuit_vv

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值