白嫖worker 自建短链服务 Url-Shorten-Worker 变身文件保管站 File Storage 保存到 R2对象存储 搭建手册
变身文件保管站 File Storage 保存到 R2对象存储
申请Cloudflare账号,略。
设置公开链接
[{"AllowedOrigins": ["*"],"AllowedMethods": ["PUT","GET","HEAD","DELETE"],"AllowedHeaders": ["*"]}]
创建R2 API
创建KV
记住这个KV的名字,以 kvtest 为例
创建Worker服务
设置绑定KV
编辑Worker的脚本内容
把原有的内容全部删掉
换成:https://github.com/crazypeace/Url-Shorten-Worker/blob/main/worker.js 的内容
变身文件保管站 lite
password: "suibianshezhishenme", // 你随便想设什么密码theme: "theme/file-r2-lite", // 变身文件保管站 lite
设置5个变量:
R2_ACCOUNT_ID = "Account ID" // - R2 账户 ID (明文变量)R2_ACCESS_KEY_ID = "Access Key ID" // - S3 API Access Key ID (建议设为加密 Secret)R2_SECRET_ACCESS_KEY = "Secret Access Key" // - S3 API Secret Access Key (建议设为加密 Secret)R2_BUCKET_NAME = "r2test" // - R2 存储桶名称 (明文变量)R2_PUBLIC_URL = "https://pub-*****.r2.dev" // - R2 公开访问 URL, 如 https://pub-xxxx.r2.dev (明文变量)
保存并部署
右上角开始使用 文件保管站 lite
https://divine-voice-e752.crazypeace.workers.dev/suibianshezhishenme
变身文件保管站 (完全体)
考虑到R2中的文件有可能体积大, 而我们在管理面板只希望显示小尺寸的缩略图.打开 Image Transformation 功能
R2_PUBLIC_URL = "https://r2test.xxxx.xxxx"
https://divine-voice-e752.crazypeace.workers.dev/suibianshezhishenme
======
后记
点击一次 "上传R2" 按钮, 再点击一次 "保存KV" 按钮, 确实太啰嗦.
但, 考虑到 Url-Shorten-Worker 整个系列的"传承", 我没有做进一步的优化.
未来我会新开一个 repo, 实现进一步的优化和增强开发.
======
配置参数的作用
const config = {password: "", // 管理面板使用密码
result_page: false, // 是否用特定的result页面来显示value
theme: "", // 管理面板的主题
cors: true, // 是否允许CORS使用API
unique_link: false, // 一个长链是否只有唯一的短链(会增加写入的使用量)
custom_link: true, // 允许自定义短链overwrite_kv: false, // 允许覆盖已存在的key
snapchat_mode: false, // 短链只能访问一次(访问后就删除了)
visit_count: true, // 使用记数(会大大增加写入的使用量, 多人共用不推荐打开)
load_kv: false, // 从KV加载全部数据(自用推荐打开, 多人共用会看到别人的数据)
system_type: "shorturl", // 系统的功能定义 // shorturl, imghost, other types {pastebin, journal}
}
======
如果要当网络记事本 PasteBin
演示站 https://pastebin.crazypeace.workers.dev/tieludasiliqiuweiyue
演示视频 https://www.youtube.com/watch?v=toBeb3DNpZc
======
如果要当图床 Image Hosting
演示站 https://imghost.crazypeace.workers.dev/imghostimghost
演示视频 https://www.youtube.com/watch?v=B7wH4tB1-O8
======
如果要当网络日记本, 支持MarkDown
演示站 https://journal.crazypeace.workers.dev/journaljournal
演示视频 https://www.youtube.com/watch?v=DZcXqyIm_R0
https://www.youtube.com/watch?v=Ra6SXZFeGM8
如果要做一次性二维码
演示站 https://snapchat.crazypeace.workers.dev/huiyingebielianaiputi
======
开发记录
直接访问域名返回404。在KV中设置一个entry,保存秘密path,只有访问这个path才显示使用页面。
https://zelikk.blogspot.com/2022/07/url-shorten-worker-hide-tutorial.html
支持自定义短链
https://zelikk.blogspot.com/2022/07/url-shorten-worker-custom.html
API 不公开服务
https://zelikk.blogspot.com/2022/07/url-shorten-worker-api-password.html
页面缓存设置过的短链
https://zelikk.blogspot.com/2022/08/url-shorten-worker-localstorage.html
长链接文本框预搜索localStorage
https://zelikk.blogspot.com/2022/08/url-shorten-worker-bootstrap-list-group-oninput.html
增加删除某条短链的按钮
https://zelikk.blogspot.com/2022/08/url-shorten-worker-delete-kv-localstorage.html
访问计数功能 可查询短链 成为功能完整的短链API系统
https://zelikk.blogspot.com/2023/11/url-shorten-worker-visit-count-api-api.html
阅后即焚功能, 可制作一次性二维码
https://zelikk.blogspot.com/2023/11/url-shorten-worker-snapchat-mode.html
增加读取 KV 中全部记录的功能
https://zelikk.blogspot.com/2024/01/url-shorten-worker-load-cloudflare-kv.html
变身网络记事本 Pastebin
https://zelikk.blogspot.com/2024/01/url-shorten-worker-pastebin.html
变身图床 Image Hosting
https://zelikk.blogspot.com/2024/01/url-shorten-worker-image-hosting-base64.html
变身日记本 NetJournal 支持Markdown
https://zelikk.blogspot.com/2024/02/url-shorten-worker-netjournal.html
https://zelikk.blogspot.com/2024/02/url-shorten-worker-netjournal-markdown.html
https://zelikk.blogspot.com/2024/04/url-shorten-worker-netjournal-markdown.html
评论
发表评论