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'}; }