mirror of
https://github.com/MarSeventh/CloudFlare-ImgBed.git
synced 2026-01-31 00:53:20 +08:00
尺寸提取功能优化
This commit is contained in:
Binary file not shown.
File diff suppressed because one or more lines are too long
BIN
css/280.6f363073.css.gz
Normal file
BIN
css/280.6f363073.css.gz
Normal file
Binary file not shown.
@@ -90,6 +90,7 @@ export async function onRequestPost(context) {
|
||||
Channel: "HuggingFace",
|
||||
ChannelName: hfChannel.name || "HuggingFace_env",
|
||||
FileSize: (fileSize / 1024 / 1024).toFixed(2),
|
||||
FileSizeBytes: fileSize,
|
||||
HfRepo: hfChannel.repo,
|
||||
HfFilePath: filePath,
|
||||
HfToken: hfChannel.token,
|
||||
|
||||
@@ -139,11 +139,8 @@ async function processFileUpload(context, formdata = null) {
|
||||
let imageDimensions = null;
|
||||
if (fileType.startsWith('image/')) {
|
||||
try {
|
||||
// JPEG 需要更多数据(EXIF 可能很大),其他格式 512 字节足够
|
||||
const lowerType = fileType.toLowerCase();
|
||||
const isJpeg = lowerType === 'image/jpeg' || lowerType === 'image/jpg' || lowerType === 'image/pjpeg';
|
||||
const readSize = isJpeg ? 65536 : 512;
|
||||
const headerBuffer = await file.slice(0, readSize).arrayBuffer();
|
||||
// 统一读取 64KB,足以覆盖 JPEG 的 EXIF 数据和其他格式
|
||||
const headerBuffer = await file.slice(0, 65536).arrayBuffer();
|
||||
imageDimensions = getImageDimensions(headerBuffer, fileType);
|
||||
} catch (error) {
|
||||
console.error('Error reading image dimensions:', error);
|
||||
@@ -287,16 +284,12 @@ async function uploadFileToCloudflareR2(context, fullId, metadata, returnLink) {
|
||||
|
||||
const R2DataBase = env.img_r2;
|
||||
|
||||
// 写入R2数据库,获取实际存储大小
|
||||
const r2Object = await R2DataBase.put(fullId, formdata.get('file'));
|
||||
// 写入R2数据库
|
||||
await R2DataBase.put(fullId, formdata.get('file'));
|
||||
|
||||
// 更新metadata
|
||||
metadata.Channel = "CloudflareR2";
|
||||
metadata.ChannelName = r2Channel.name || "R2_env";
|
||||
// 使用 R2 返回的实际文件大小
|
||||
if (r2Object && r2Object.size) {
|
||||
metadata.FileSize = (r2Object.size / 1024 / 1024).toFixed(2);
|
||||
}
|
||||
|
||||
// 图像审查,采用R2的publicUrl
|
||||
const R2PublicUrl = r2Channel.publicUrl;
|
||||
@@ -782,7 +775,6 @@ async function uploadFileToHuggingFace(context, fullId, metadata, returnLink) {
|
||||
// 更新 metadata
|
||||
metadata.Channel = "HuggingFace";
|
||||
metadata.ChannelName = hfChannel.name || "HuggingFace_env";
|
||||
metadata.FileSize = (file.size / 1024 / 1024).toFixed(2);
|
||||
metadata.HfRepo = hfChannel.repo;
|
||||
metadata.HfFilePath = hfFilePath;
|
||||
metadata.HfToken = hfChannel.token;
|
||||
|
||||
@@ -1 +1 @@
|
||||
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/logo.png"><link rel="apple-touch-icon" href="/logo.png"><link rel="mask-icon" href="/logo.png" color="#f4b400"><meta name="description" content="Sanyue ImgHub - A modern file hosting platform"><meta name="keywords" content="Sanyue, ImgHub, file hosting, image hosting, cloud storage"><meta name="author" content="SanyueQi"><title>Sanyue ImgHub</title><script defer="defer" src="/js/chunk-vendors.92518219.js"></script><script defer="defer" src="/js/app.1611e1ad.js"></script><link href="/css/chunk-vendors.4363ed49.css" rel="stylesheet"><link href="/css/app.3e1508bd.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but sanyue_imghub doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
|
||||
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/logo.png"><link rel="apple-touch-icon" href="/logo.png"><link rel="mask-icon" href="/logo.png" color="#f4b400"><meta name="description" content="Sanyue ImgHub - A modern file hosting platform"><meta name="keywords" content="Sanyue, ImgHub, file hosting, image hosting, cloud storage"><meta name="author" content="SanyueQi"><title>Sanyue ImgHub</title><script defer="defer" src="/js/chunk-vendors.92518219.js"></script><script defer="defer" src="/js/app.28705dac.js"></script><link href="/css/chunk-vendors.4363ed49.css" rel="stylesheet"><link href="/css/app.3e1508bd.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but sanyue_imghub doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
|
||||
BIN
index.html.gz
BIN
index.html.gz
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
2
js/280.65ead6f8.js
Normal file
2
js/280.65ead6f8.js
Normal file
File diff suppressed because one or more lines are too long
BIN
js/280.65ead6f8.js.gz
Normal file
BIN
js/280.65ead6f8.js.gz
Normal file
Binary file not shown.
1
js/280.65ead6f8.js.map
Normal file
1
js/280.65ead6f8.js.map
Normal file
File diff suppressed because one or more lines are too long
BIN
js/280.65ead6f8.js.map.gz
Normal file
BIN
js/280.65ead6f8.js.map.gz
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
BIN
js/app.28705dac.js.gz
Normal file
BIN
js/app.28705dac.js.gz
Normal file
Binary file not shown.
File diff suppressed because one or more lines are too long
BIN
js/app.28705dac.js.map.gz
Normal file
BIN
js/app.28705dac.js.map.gz
Normal file
Binary file not shown.
Reference in New Issue
Block a user