fix: 修改uploadFiles和container上传

This commit is contained in:
2024-10-24 09:23:34 +08:00
parent 0eae9458c6
commit d8fec88e54
4 changed files with 115 additions and 93 deletions

View File

@@ -65,7 +65,25 @@ export const cachePage = async (page: PageModel, opts: { tokenUser: any; key; ve
},
];
};
export const uploadMinioContainer = async ({ tokenUser, key, version, code, filePath }) => {
if ((filePath as string).includes('..')) {
throw new CustomError('file path is invalid');
}
const minioKeyVersion = `${tokenUser.username}/${key}/${version}`;
const minioPath = path.join(minioKeyVersion, filePath);
console.log('minioPath', minioPath);
// const isHTML = filePath.endsWith('.html');
const name = minioPath.replace(minioKeyVersion + '/', '');
await minioClient.putObject(bucketName, minioPath, code, code.length, {
'Content-Type': getContentType(filePath),
'app-source': 'user-app',
'Cache-Control': 'no-cache', // 缓存一年
});
return {
name,
path: minioPath,
};
};
export const uploadMinio = async ({ tokenUser, key, version, path, filePath }) => {
const minioPath = `${tokenUser.username}/${key}/${version}/${path}`;
const isHTML = filePath.endsWith('.html');