From 6da58e3a7b8f80fa0ed36be797aba03a1f3a70e7 Mon Sep 17 00:00:00 2001 From: MarSeventh <1193267292@qq.com> Date: Tue, 10 Sep 2024 13:31:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96WEBP=E5=8A=A8=E5=9B=BE?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++++ functions/upload.js | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1d91d8f7..22764a32 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ **体验地址**:[Sanyue ImgHub (demo-cloudflare-imgbed.pages.dev)](https://demo-cloudflare-imgbed.pages.dev/) +> 访问码:cfbed +> +> **为什么有人攻击我的演示站!一直上传重复的图片什么意思?维护项目已经很累了,请自重好吗?** + **体验视频**:[CloudFlare免费图床,轻松守护你的每一份精彩!_哔哩哔哩_bilibili](https://www.bilibili.com/video/BV1y3WGe4EGh/?vd_source=da5ecbe595e41089cd1bed95932b8bfd) **相关优质博文(感谢每一位鼎力支持的热心大佬):** diff --git a/functions/upload.js b/functions/upload.js index 8192757d..45526992 100644 --- a/functions/upload.js +++ b/functions/upload.js @@ -60,6 +60,10 @@ export async function onRequestPost(context) { // Contents of context object const newFileName = fileName.replace(/\.gif$/, '.jpeg'); const newFile = new File([formdata.get('file')], newFileName, { type: fileType }); formdata.set('file', newFile); + } else if (fileExt === 'webp') { + const newFileName = fileName.replace(/\.webp$/, '.jpeg'); + const newFile = new File([formdata.get('file')], newFileName, { type: fileType }); + formdata.set('file', newFile); } const fileTypeMap = { @@ -76,7 +80,7 @@ export async function onRequestPost(context) { // Contents of context object : defaultType; // GIF 特殊处理 - if (fileType === 'image/gif' || fileExt === 'gif') { + if (fileType === 'image/gif' || fileType === 'image/webp' || fileExt === 'gif' || fileExt === 'webp') { sendFunction = {'url': 'sendAnimation', 'type': 'animation'}; }