From 6a159dcbfb2ad515dede081b3fb346c7a2a2e1da Mon Sep 17 00:00:00 2001 From: jenken827 Date: Sat, 6 Dec 2025 15:15:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81svg=E5=92=8Cico?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/upload/index.js | 5 ++++- functions/utils/telegramAPI.js | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/functions/upload/index.js b/functions/upload/index.js index d23434b..c087c84 100644 --- a/functions/upload/index.js +++ b/functions/upload/index.js @@ -406,7 +406,7 @@ async function uploadFileToTelegram(context, fullId, metadata, fileExt, fileName const newFileName = fileName.replace(/\.webp$/, '.jpeg'); const newFile = new File([formdata.get('file')], newFileName, { type: fileType }); formdata.set('file', newFile); - } + } // 选择对应的发送接口 const fileTypeMap = { @@ -425,6 +425,8 @@ async function uploadFileToTelegram(context, fullId, metadata, fileExt, fileName // GIF 发送接口特殊处理 if (fileType === 'image/gif' || fileType === 'image/webp' || fileExt === 'gif' || fileExt === 'webp') { sendFunction = { 'url': 'sendAnimation', 'type': 'animation' }; + }else if (fileType === 'image/svg+xml' || fileType === 'image/x-icon') { + sendFunction = { 'url': 'sendDocument', 'type': 'document' }; } // 根据服务端压缩设置处理接口:从参数中获取serverCompress,如果为false,则使用sendDocument接口 @@ -477,6 +479,7 @@ async function uploadFileToTelegram(context, fullId, metadata, fileExt, fileName waitUntil(endUpload(context, fullId, metadata)); } catch (error) { + console.log('Telegram upload error:', error.message); res = createResponse('upload error, check your environment params about telegram channel!', { status: 400 }); } finally { return res; diff --git a/functions/utils/telegramAPI.js b/functions/utils/telegramAPI.js index 24b33fc..e0523f8 100644 --- a/functions/utils/telegramAPI.js +++ b/functions/utils/telegramAPI.js @@ -36,8 +36,8 @@ export class TelegramAPI { headers: this.defaultHeaders, body: formData }); - - if (!response.ok) { + console.log('Telegram API response:', response.status, response.statusText); + if (!response.ok) { throw new Error(`Telegram API error: ${response.statusText}`); }