Opt:优化大文件上传和访问

This commit is contained in:
MarSeventh
2025-07-27 23:06:46 +08:00
parent d00916bf92
commit 4d9c618ff7
19 changed files with 19 additions and 14 deletions

3
.gitignore vendored
View File

@@ -1,3 +1,4 @@
.wrangler/* .wrangler/*
data/* data/*
node_modules node_modules
.DS_Store

Binary file not shown.

File diff suppressed because one or more lines are too long

BIN
css/863.167c3347.css.gz Normal file

Binary file not shown.

View File

@@ -341,15 +341,19 @@ async function handleR2File(context, fileId, encodedFileName, fileType) {
let object; let object;
if (range) { if (range) {
// 处理Range请求(用于大文件流式传输) // 处理Range请求
const matches = range.match(/bytes=(\d+)-(\d*)/); const matches = range.match(/bytes=(\d+)-(\d*)/);
if (matches) { if (matches) {
const start = parseInt(matches[1]); const start = parseInt(matches[1]);
const end = matches[2] ? parseInt(matches[2]) : undefined; const end = matches[2] ? parseInt(matches[2]) : undefined;
const rangeOptions = { offset: start }; const rangeOptions = {
range: {
offset: start
}
};
if (end !== undefined) { if (end !== undefined) {
rangeOptions.length = end - start + 1; rangeOptions.range.length = end - start + 1;
} }
object = await R2DataBase.get(fileId, rangeOptions); object = await R2DataBase.get(fileId, rangeOptions);

View File

@@ -1,4 +1,4 @@
<!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/app.09736f66.js"></script><link href="/css/app.10673e72.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><style>/* 下拉菜单样式 */ <!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/app.317242a7.js"></script><link href="/css/app.10673e72.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><style>/* 下拉菜单样式 */
.el-dropdown__popper.el-popper { .el-dropdown__popper.el-popper {
border-radius: 12px; border-radius: 12px;
border: none; border: none;

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

2
js/863.ed1005d9.js Normal file

File diff suppressed because one or more lines are too long

BIN
js/863.ed1005d9.js.gz Normal file

Binary file not shown.

File diff suppressed because one or more lines are too long

BIN
js/863.ed1005d9.js.map.gz Normal file

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

BIN
js/app.317242a7.js.gz Normal file

Binary file not shown.

File diff suppressed because one or more lines are too long