PicGo和码云实现自建图床
本帖最后由 zxdsb666. 于 2022-3-28 09:46 编辑# PicGo和码云实现自建图床
# PS:20220327补充
近期看到有小伙伴回复自己看了文章发现gitee看不到内容,所以这里直接贴一个教程的pdf文件
请看本帖的附件内容
## 最好的教程
知乎的一篇教程:https://zhuanlan.zhihu.com/p/102594554
## 测试图床链接:
链接1 :
https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200318234353.png
链接2:
https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200318234621.png
链接3:
https://gitee.com/lazyTimes/imageReposity/raw/master/jiuhe/20200319094133.png



## 为什么要使用码云代替图床
+ github毕竟是外国服务器,上传过程中因为网络问题有可能会无法使用的情况
+ 码云作为国内的“github”,访问和上传速度更快,所以使用码云更为方便
+ 目前`PicGo 2.0`之后已经有人集成了插件,使用和github一样简单好用
## 步骤:
### 1. 下载PicGo
官网地址:https://molunerfinn.com/PicGo/
Github 快捷网址:https://github.com/Molunerfinn/PicGo/releases/tag/v2.2.2 选择对应的版本下载即可

更多信息访问Github:https://github.com/Molunerfinn/PicGo
### 2. 安装PicGo
安装过程就忽略了,安装完成之后打开软件

### 3. PicGo 安装gitee 插件
前提条件:**注意PicGo安装的前提条件是2.0版本之后新增的插件功能!!!**

将鼠标滚轮滚到最下面,会发现有一个插件设置

选择安装 `gitee-uploader 1.1.2 `这个插件
> **安装失败如何解决**?
>
> 注意该插件需要node.js 的环境,Node.js的安装如下
>
> http://nodejs.cn/download/
>
> 进入中文官网之后,安装对应的版本即可
>
> window 下面的exe程序安装之后会自动的配置环境变量,这时候我们可以使用命令查一下是否有Node环境
>
> 1. win 键 + R 打开**运行**窗口
>
> 
>
> 2. 输入命令`node -v`
>
> 
>
> 3. 如果出现如上所示的内容则证明安装成功
### 4. 码云搭建图床仓库
1. 进入自己的码云:https://gitee.com/lazyTimes/projects 这是我的码云地址

2. 选择右上角有一个 `"+"`号,选择新建仓库

3. 填写基本信息,页面翻到最下面,选择保存
!(C:\Users\admin\AppData\Roaming\Typora\typora-user-images\image-20200319133550209.png)
4. 新建仓库成功

### 5. 获取gitee私人令牌
和github一样,在最终设置之前我们需要获取一下gitee令牌用于上传
1. 登录gitee之后,右上角选择

2. 选择“私人令牌”

3. 选择“生成令牌”,进入到令牌到创建页面

4. 勾选如图到内容,一般只需要用到前面几项就可以满足我们到需求。按要求输入密码即可生成成功

5. 生成令牌成功,将令牌内容保存在自己到笔记,防止忘记

经过如上步骤之后,我们基本就算是大功告成了,现在只需要在PicGo里面配置一下即可
### 6. PicGo 配置
+ repo:必填,填写gitee上面的仓库名称
+ branch:一般默认master 即可,有需要可以建立自己到分支
+ tolken:要用到上一节所述到私人令牌,如果忘记了可以进入页面之后重新获取一下新令牌
+ path:写上文件存放到位置,一般写上`img`即可
+ customPath:定义传输到格式,一般可以不用管
+ customUrl:自定义上传到链接
> 不知道怎么获取repo地址?
>
> 1. 进入自己到图床仓库到主页,复制地址栏到内容
>
> 2. 复制下方到用户和项目名称
>
> **注意中间到内容不要存在空格,删除注意不要多删除字符造成上传失败**
>
> 
最终到配置结果如下所示

# 总结
由于github存在限制加上外网访问普遍较慢到问题,如果网速不给力并且没有科学上网工具建议使用gitee作为图形仓库。可以在1S内上传,非常方便。赶紧把gitee用起来把 坐久落花多 发表于 2020-10-28 10:05
上传失败
请检查配置和上传的文件是否符合要求
--------------------------------------------
一般是配置没配对,多尝试一下 本帖最后由 1983 于 2021-9-18 16:41 编辑
纠正下楼主,输入命令node -v,显示出版本号,并不表示成功,
至少我跟着楼主的操作,我这边,在对应的插件处,看到有三个插件,逐个点击安装,全部失败,包括导入本地插件也失败。
我第一个用的是node-v14.17.4-x64.msi,提示【只支持win8以上】。我是win 7。
下载好 Node-v12.16.0-x64.msi,安装完成,输入命令node -v,显示版本号,反正安装gitee插件一直失败,
2021-08-10 04:21:19 插件安装失败,失败码为1,错误日志为internal/modules/cjs/loader.js:984
throw err;
^
Error: Cannot find module 'find-npm-prefix'
Require stack:
- D:\Program Files (x86)\nodejs\node_modules\npm\lib\config\load-prefix.js
- D:\Program Files (x86)\nodejs\node_modules\npm\lib\config\core.js
- D:\Program Files (x86)\nodejs\node_modules\npm\lib\npm.js
- D:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:981:15)
at Function.Module._load (internal/modules/cjs/loader.js:863:27)
at Module.require (internal/modules/cjs/loader.js:1043:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (D:\Program Files (x86)\nodejs\node_modules\npm\lib\config\load-prefix.js:3:18)
at Module._compile (internal/modules/cjs/loader.js:1157:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1177:10)
at Module.load (internal/modules/cjs/loader.js:1001:32)
at Function.Module._load (internal/modules/cjs/loader.js:900:14)
at Module.require (internal/modules/cjs/loader.js:1043:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'D:\\Program Files (x86)\\nodejs\\node_modules\\npm\\lib\\config\\load-prefix.js',
'D:\\Program Files (x86)\\nodejs\\node_modules\\npm\\lib\\config\\core.js',
'D:\\Program Files (x86)\\nodejs\\node_modules\\npm\\lib\\npm.js',
'D:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js'
]
}
internal/modules/cjs/loader.js:984
throw err;
^
Error: Cannot find module 'find-npm-prefix'
Require stack:
- D:\Program Files (x86)\nodejs\node_modules\npm\lib\config\load-prefix.js
- D:\Program Files (x86)\nodejs\node_modules\npm\lib\config\core.js
- D:\Program Files (x86)\nodejs\node_modules\npm\lib\npm.js
- D:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:981:15)
at Function.Module._load (internal/modules/cjs/loader.js:863:27)
at Module.require (internal/modules/cjs/loader.js:1043:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (D:\Program Files (x86)\nodejs\node_modules\npm\lib\config\load-prefix.js:3:18)
at Module._compile (internal/modules/cjs/loader.js:1157:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1177:10)
at Module.load (internal/modules/cjs/loader.js:1001:32)
at Function.Module._load (internal/modules/cjs/loader.js:900:14)
at Module.require (internal/modules/cjs/loader.js:1043:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'D:\\Program Files (x86)\\nodejs\\node_modules\\npm\\lib\\config\\load-prefix.js',
'D:\\Program Files (x86)\\nodejs\\node_modules\\npm\\lib\\config\\core.js',
'D:\\Program Files (x86)\\nodejs\\node_modules\\npm\\lib\\npm.js',
'D:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js'
]
}
后来网络搜索,看到有网友说:既然失败,不如直接 npm 插件。打算一试。
命令窗口 npm,一查 输入命令npm -v,报错和上面一致,
傻乎乎的我,以为是npm没装好,打算卸载node,用控制面板的程序+360软件管家来卸载,两个都提示“The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The eror code is 2330.”
说明这个版本的Node-v12.16.0-x64.msi 看似安装完成,但其实安装就有问题。
啥问题?npm都没装好咯,网络搜索得知:这个Node-v12.16.0-x64.msi版本不适合 win7 系统,
马上找到 win 开始菜单-所有程序-node.js-Uninstall Node.js,卸载,成功,还是用node自带的卸载工具才有用。。。
最后装了Node-v8.11.1-x64.msi ,输入命令node -v,没问题,输入命令npm -v,也没问题。
打开Picgo,安装gitee 插件,总算成功了。。。
很详细 ,,给力~ 本帖最后由 pxhzai 于 2020-10-28 01:32 编辑
有个lanzou更好
https://wwx.lanzoux.com/ijhBchsrp8f
有的图片外链不显示需要点进去看https://gitee.com/qq62/tc/raw/master/pig/22.png
http删除s://gitee.com/qq62/tc/raw/master/pig/22.png
https://gitee.com/qq62/tc/raw/master/pig/22.png 这东西稳定吧。。 感谢分享,学习了 思路不错,感谢 这个不错,很有用 有个不太好的地方就是超过1M的图片,访问需要登录,外链不让看
上传失败
请检查配置和上传的文件是否符合要求
--------------------------------------------
这是哪里出了问题?
轩宸 发表于 2020-10-28 08:50
有个不太好的地方就是超过1M的图片,访问需要登录,外链不让看
确实有这个问题,可以结合免费的和自建的配合使用