mirror of
https://github.com/ZSCGR/CloudFlare-ImgBed.git
synced 2026-08-13 04:03:42 +08:00
优化WEBP动图上传
This commit is contained in:
@@ -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)
|
||||
|
||||
**相关优质博文(感谢每一位鼎力支持的热心大佬):**
|
||||
|
||||
+5
-1
@@ -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'};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user