cloudflare R2作为图床的管理和同步

   
摘要GPT
摘要小助理暂时失联跑路啦……😜

因为我把r2当图床,但是大量图片没有经过压缩处理,浪费带宽资源,所以有了这篇记录,

大致意思就是把r2的图片同步到电脑上,使用压缩工具批量压缩处理之后,在同步到r2

为什么不使用linux去搞,因为繁琐问题多,不稳定

1:下载rclone: https://lzui.lanzv.com/iE6SN1mn693a

先创建存储桶,例如imgs是我的存储桶名称

2:把rclone-v1.63.0-windows-amd64.zip解压到D盘,进入目录,在rclone.conf文件配置r2,

只需要配置 access_key_id,secret_access_key,endpoint三个参数即可

3:新建文件,写入代码,将后缀改为bat(双击运行)

@echo off
cd /d D:\rclone-v1.63.0-windows-amd64
rclone sync r2:imgs\2024 C:\Users\Administrator\Desktop\imgs\2024 --ignore-existing -u -v -P --transfers=20 --ignore-errors --buffer-size=128M --check-first --checkers=10 --drive-acknowledge-abuse
pause

这条代码的意思是:

把我的imgs存储桶下的2024文件夹同步到

C:\Users\Administrator\Desktop\imgs\2024 目录,根据你的情况去修改目录

rclone sync: 同步的意思,也可以把sync改成copy

r2:imgs imgs是我的存储同名称,r2不要改

D:\rclone-v1.63.0-windows-amd64 是rclone所在目录

–drive-acknowledge-abuse 是针对谷歌网盘,可去掉,因为谷歌容易把文件当敏感资源不给下载甚至报毒 谷歌的教程博客有

反过来同步就是:本地同步到r2

@echo off
cd /d D:\rclone-v1.63.0-windows-amd64
rclone sync C:\Users\Administrator\Desktop\imgs\2024 r2:imgs\2024 --ignore-existing -u -v -P --transfers=20 --ignore-errors --buffer-size=128M --check-first --checkers=10 --drive-acknowledge-abuse
pause

图片批量压缩工具:

项目:https://github.com/meowtec/Imagine

下载地址:https://lzui.lanzv.com/i9Y6U1mn69wj

知识共享许可证 CC BY-NC-SA 4.0
最后更新于 2024-07-17 18:28
使用 Hugo 构建
主题 hugo-magic小洋葱 魔改 由 Jimmy 设计
Written by Human, Not by AI