update
This commit is contained in:
parent
cf82967060
commit
3938a0f87e
@ -31,8 +31,8 @@
|
|||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@kevisual/logger": "^0.0.2",
|
"@kevisual/logger": "^0.0.3",
|
||||||
"@kevisual/oss": "^0.0.7",
|
"@kevisual/oss": "^0.0.11",
|
||||||
"@rollup/plugin-commonjs": "^28.0.3",
|
"@rollup/plugin-commonjs": "^28.0.3",
|
||||||
"@rollup/plugin-json": "^6.1.0",
|
"@rollup/plugin-json": "^6.1.0",
|
||||||
"@rollup/plugin-node-resolve": "^16.0.1",
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
||||||
@ -55,10 +55,12 @@
|
|||||||
"@kevisual/query-config": "^0.0.2",
|
"@kevisual/query-config": "^0.0.2",
|
||||||
"@kevisual/router": "0.0.14",
|
"@kevisual/router": "0.0.14",
|
||||||
"@kevisual/use-config": "^1.0.15",
|
"@kevisual/use-config": "^1.0.15",
|
||||||
|
"@types/lodash-es": "^4.17.12",
|
||||||
"archiver": "^7.0.1",
|
"archiver": "^7.0.1",
|
||||||
"busboy": "^1.6.0",
|
"busboy": "^1.6.0",
|
||||||
"cookie": "^1.0.2",
|
"cookie": "^1.0.2",
|
||||||
"ioredis": "^5.6.1",
|
"ioredis": "^5.6.1",
|
||||||
|
"lodash-es": "^4.17.21",
|
||||||
"minio": "^8.0.5",
|
"minio": "^8.0.5",
|
||||||
"nanoid": "^5.1.5",
|
"nanoid": "^5.1.5",
|
||||||
"send": "^1.2.0",
|
"send": "^1.2.0",
|
||||||
|
43
pnpm-lock.yaml
generated
43
pnpm-lock.yaml
generated
@ -29,6 +29,9 @@ importers:
|
|||||||
'@kevisual/use-config':
|
'@kevisual/use-config':
|
||||||
specifier: ^1.0.15
|
specifier: ^1.0.15
|
||||||
version: 1.0.15(dotenv@16.4.7)
|
version: 1.0.15(dotenv@16.4.7)
|
||||||
|
'@types/lodash-es':
|
||||||
|
specifier: ^4.17.12
|
||||||
|
version: 4.17.12
|
||||||
archiver:
|
archiver:
|
||||||
specifier: ^7.0.1
|
specifier: ^7.0.1
|
||||||
version: 7.0.1
|
version: 7.0.1
|
||||||
@ -41,6 +44,9 @@ importers:
|
|||||||
ioredis:
|
ioredis:
|
||||||
specifier: ^5.6.1
|
specifier: ^5.6.1
|
||||||
version: 5.6.1
|
version: 5.6.1
|
||||||
|
lodash-es:
|
||||||
|
specifier: ^4.17.21
|
||||||
|
version: 4.17.21
|
||||||
minio:
|
minio:
|
||||||
specifier: ^8.0.5
|
specifier: ^8.0.5
|
||||||
version: 8.0.5
|
version: 8.0.5
|
||||||
@ -55,11 +61,11 @@ importers:
|
|||||||
version: 6.37.7(pg@8.13.3)
|
version: 6.37.7(pg@8.13.3)
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@kevisual/logger':
|
'@kevisual/logger':
|
||||||
specifier: ^0.0.2
|
specifier: ^0.0.3
|
||||||
version: 0.0.2
|
version: 0.0.3
|
||||||
'@kevisual/oss':
|
'@kevisual/oss':
|
||||||
specifier: ^0.0.7
|
specifier: ^0.0.11
|
||||||
version: 0.0.7
|
version: 0.0.11
|
||||||
'@rollup/plugin-commonjs':
|
'@rollup/plugin-commonjs':
|
||||||
specifier: ^28.0.3
|
specifier: ^28.0.3
|
||||||
version: 28.0.3(rollup@4.40.2)
|
version: 28.0.3(rollup@4.40.2)
|
||||||
@ -131,11 +137,11 @@ packages:
|
|||||||
'@kevisual/load@0.0.6':
|
'@kevisual/load@0.0.6':
|
||||||
resolution: {integrity: sha512-+3YTFehRcZ1haGel5DKYMUwmi5i6f2psyaPZlfkKU/cOXgkpwoG9/BEqPCnPjicKqqnksEpixVRkyHJ+5bjLVA==}
|
resolution: {integrity: sha512-+3YTFehRcZ1haGel5DKYMUwmi5i6f2psyaPZlfkKU/cOXgkpwoG9/BEqPCnPjicKqqnksEpixVRkyHJ+5bjLVA==}
|
||||||
|
|
||||||
'@kevisual/logger@0.0.2':
|
'@kevisual/logger@0.0.3':
|
||||||
resolution: {integrity: sha512-4NVdNsOHmMRg+OuZPoNNdI3p7jRII7lMJHRar1IoBck7fFIV7YGMNQirrrjk07MHv+Eh+U+uUljjgEWbse92RA==}
|
resolution: {integrity: sha512-8emqxg+ab62WAK6VY4FQqetXPSSVKFAjGctD1NDbdnxt7YWuI/PyuDltCpsVz+uvWpV1dO5OKZOoHU7ow59Omw==}
|
||||||
|
|
||||||
'@kevisual/oss@0.0.7':
|
'@kevisual/oss@0.0.11':
|
||||||
resolution: {integrity: sha512-saPN4A1CaGvSkFZzLE4zMsm+WwXi6Z97Yavz6koWFziuJIi/ay0793A4EDZ0iIpE9MMTRLYsuSQTUxDzsZV4Kg==}
|
resolution: {integrity: sha512-oxC6KVTNeDUaoAAVHyNVhSg9JPj1FzwbP5PkYvTj2VHC3PvFtvG//m6Zii7yKpFv7itKzMuS7/9xDMdI5lPhaA==}
|
||||||
|
|
||||||
'@kevisual/permission@0.0.1':
|
'@kevisual/permission@0.0.1':
|
||||||
resolution: {integrity: sha512-nSX2LzbPkU3YAMegbUFGU8tfmtFb7dcF5edqzm+gI6crcyCL1JzIB9HAYNEeEVIljLxuREwM/vVg9aFmF4cz9Q==}
|
resolution: {integrity: sha512-nSX2LzbPkU3YAMegbUFGU8tfmtFb7dcF5edqzm+gI6crcyCL1JzIB9HAYNEeEVIljLxuREwM/vVg9aFmF4cz9Q==}
|
||||||
@ -330,6 +336,12 @@ packages:
|
|||||||
'@types/http-proxy@1.17.16':
|
'@types/http-proxy@1.17.16':
|
||||||
resolution: {integrity: sha512-sdWoUajOB1cd0A8cRRQ1cfyWNbmFKLAqBB89Y8x5iYyG/mkJHc0YUH8pdWBy2omi9qtCpiIgGjuwO0dQST2l5w==}
|
resolution: {integrity: sha512-sdWoUajOB1cd0A8cRRQ1cfyWNbmFKLAqBB89Y8x5iYyG/mkJHc0YUH8pdWBy2omi9qtCpiIgGjuwO0dQST2l5w==}
|
||||||
|
|
||||||
|
'@types/lodash-es@4.17.12':
|
||||||
|
resolution: {integrity: sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==}
|
||||||
|
|
||||||
|
'@types/lodash@4.17.16':
|
||||||
|
resolution: {integrity: sha512-HX7Em5NYQAXKW+1T+FiuG27NGwzJfCX3s1GjOa7ujxZa52kjJLOr4FUxT+giF6Tgxv1e+/czV/iTtBw27WTU9g==}
|
||||||
|
|
||||||
'@types/mime@1.3.5':
|
'@types/mime@1.3.5':
|
||||||
resolution: {integrity: sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==}
|
resolution: {integrity: sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==}
|
||||||
|
|
||||||
@ -856,6 +868,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-b94GiNHQNy6JNTrt5w6zNyffMrNkXZb3KTkCZJb2V1xaEGCk093vkZ2jk3tpaeP33/OiXC+WvK9AxUebnf5nbw==}
|
resolution: {integrity: sha512-b94GiNHQNy6JNTrt5w6zNyffMrNkXZb3KTkCZJb2V1xaEGCk093vkZ2jk3tpaeP33/OiXC+WvK9AxUebnf5nbw==}
|
||||||
engines: {node: '>= 0.6.3'}
|
engines: {node: '>= 0.6.3'}
|
||||||
|
|
||||||
|
lodash-es@4.17.21:
|
||||||
|
resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==}
|
||||||
|
|
||||||
lodash.defaults@4.2.0:
|
lodash.defaults@4.2.0:
|
||||||
resolution: {integrity: sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==}
|
resolution: {integrity: sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==}
|
||||||
|
|
||||||
@ -1478,9 +1493,9 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
eventemitter3: 5.0.1
|
eventemitter3: 5.0.1
|
||||||
|
|
||||||
'@kevisual/logger@0.0.2': {}
|
'@kevisual/logger@0.0.3': {}
|
||||||
|
|
||||||
'@kevisual/oss@0.0.7': {}
|
'@kevisual/oss@0.0.11': {}
|
||||||
|
|
||||||
'@kevisual/permission@0.0.1': {}
|
'@kevisual/permission@0.0.1': {}
|
||||||
|
|
||||||
@ -1636,6 +1651,12 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 22.15.17
|
'@types/node': 22.15.17
|
||||||
|
|
||||||
|
'@types/lodash-es@4.17.12':
|
||||||
|
dependencies:
|
||||||
|
'@types/lodash': 4.17.16
|
||||||
|
|
||||||
|
'@types/lodash@4.17.16': {}
|
||||||
|
|
||||||
'@types/mime@1.3.5': {}
|
'@types/mime@1.3.5': {}
|
||||||
|
|
||||||
'@types/ms@2.1.0': {}
|
'@types/ms@2.1.0': {}
|
||||||
@ -2167,6 +2188,8 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
readable-stream: 2.3.8
|
readable-stream: 2.3.8
|
||||||
|
|
||||||
|
lodash-es@4.17.21: {}
|
||||||
|
|
||||||
lodash.defaults@4.2.0: {}
|
lodash.defaults@4.2.0: {}
|
||||||
|
|
||||||
lodash.isarguments@3.1.0: {}
|
lodash.isarguments@3.1.0: {}
|
||||||
|
@ -74,14 +74,14 @@ export const getMetadata = (pathname: string) => {
|
|||||||
if (isHtml) {
|
if (isHtml) {
|
||||||
meta = {
|
meta = {
|
||||||
...meta,
|
...meta,
|
||||||
'Content-Type': 'text/html; charset=utf-8',
|
'content-type': 'text/html; charset=utf-8',
|
||||||
'Cache-Control': 'no-cache',
|
'cache-control': 'no-cache',
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
meta = {
|
meta = {
|
||||||
...meta,
|
...meta,
|
||||||
'Content-Type': getContentType(pathname),
|
'content-type': getContentType(pathname),
|
||||||
'Cache-Control': 'max-age=31536000, immutable',
|
'cache-control': 'max-age=31536000, immutable',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return meta;
|
return meta;
|
||||||
@ -118,10 +118,18 @@ export const postProxy = async (req: IncomingMessage, res: ServerResponse, opts:
|
|||||||
res.writeHead(code, { 'Content-Type': 'application/json' });
|
res.writeHead(code, { 'Content-Type': 'application/json' });
|
||||||
res.end(JSON.stringify({ code: code, data: data, message: message || 'success' }));
|
res.end(JSON.stringify({ code: code, data: data, message: message || 'success' }));
|
||||||
};
|
};
|
||||||
|
let statMeta: any = {};
|
||||||
if (!force) {
|
if (!force) {
|
||||||
const check = await oss.checkObjectHash(objectName, hash);
|
const check = await oss.checkObjectHash(objectName, hash, meta);
|
||||||
if (check) {
|
statMeta = check?.metaData || {};
|
||||||
return end({ success: true, hash }, '文件已存在');
|
let isNewMeta = false;
|
||||||
|
if (check.success && JSON.stringify(meta) !== '{}' && !check.equalMeta) {
|
||||||
|
meta = { ...statMeta, ...getMetadata(pathname), ...meta };
|
||||||
|
isNewMeta = true;
|
||||||
|
await oss.replaceObject(objectName, { ...meta });
|
||||||
|
}
|
||||||
|
if (check.success) {
|
||||||
|
return end({ success: true, hash, meta, isNewMeta, equalMeta: check.equalMeta }, '文件已存在');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const bb = busboy({
|
const bb = busboy({
|
||||||
@ -135,16 +143,19 @@ export const postProxy = async (req: IncomingMessage, res: ServerResponse, opts:
|
|||||||
bb.on('file', async (name, file, info) => {
|
bb.on('file', async (name, file, info) => {
|
||||||
fileProcessed = true;
|
fileProcessed = true;
|
||||||
try {
|
try {
|
||||||
|
// console.log('file', stat?.metaData);
|
||||||
|
// await sleep(2000);
|
||||||
await oss.putObject(
|
await oss.putObject(
|
||||||
objectName,
|
objectName,
|
||||||
file,
|
file,
|
||||||
{
|
{
|
||||||
|
...statMeta,
|
||||||
...getMetadata(pathname),
|
...getMetadata(pathname),
|
||||||
...meta,
|
...meta,
|
||||||
},
|
},
|
||||||
{ check: true, isStream: true },
|
{ check: false, isStream: true },
|
||||||
);
|
);
|
||||||
end({ success: true, name, info }, '上传成功', 200);
|
end({ success: true, name, info, meta: meta?.metaData, statMeta }, '上传成功', 200);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
end({ error: error }, '上传失败', 500);
|
end({ error: error }, '上传失败', 500);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user