This commit is contained in:
2026-01-18 00:31:57 +08:00
parent fee5076e16
commit 5e5f4f6543
2 changed files with 149 additions and 56 deletions

View File

@@ -39,6 +39,14 @@ export const s3Proxy = async (req: http.IncomingMessage, res: http.ServerRespons
if (objectPath.startsWith(s3.bucket + '/')) {
objectPath = objectPath.replace(s3.bucket + '/', '');
}
if (objectPath.endsWith('/')) {
// 获取目录列表
res.statusCode = 200;
res.setHeader('Content-Type', 'application/json; charset=utf-8');
const list = await oss.listObjects(objectPath);
res.end(JSON.stringify(list, null, 2));
return;
}
oss.getObject(objectPath).then((response) => {
if (!response.Body) {
res.statusCode = 404;