This commit is contained in:
2025-12-03 18:17:04 +08:00
parent 98f68fe300
commit 46aa293cce
3 changed files with 98 additions and 9 deletions

View File

@@ -156,6 +156,11 @@ export const postProxy = async (req: IncomingMessage, res: ServerResponse, opts:
const params = _u.searchParams;
const force = !!params.get('force');
const hash = params.get('hash');
const _fileSize: string = params.get('size');
let fileSize: number | undefined = undefined;
if (_fileSize) {
fileSize = parseInt(_fileSize, 10)
}
let meta = parseSearchValue(params.get('meta'), { decode: true });
if (!hash && !force) {
return opts?.createNotFoundPage?.('no hash');
@@ -193,8 +198,6 @@ export const postProxy = async (req: IncomingMessage, res: ServerResponse, opts:
bb.on('file', async (name, file, info) => {
fileProcessed = true;
try {
// console.log('file', stat?.metaData);
// await sleep(2000);
await oss.putObject(
objectName,
file,
@@ -203,9 +206,10 @@ export const postProxy = async (req: IncomingMessage, res: ServerResponse, opts:
...getMetadata(pathname),
...meta,
},
{ check: false, isStream: true },
{ check: false, isStream: true, size: fileSize },
);
end({ success: true, name, info, isNew: true, hash, meta: meta?.metaData, statMeta }, '上传成功', 200);
} catch (error) {
end({ error: error }, '上传失败', 500);
}