fix: fix chunk

This commit is contained in:
xion 2025-03-31 21:22:13 +08:00
parent e0ac1b7d27
commit 466ac1bcf0
4 changed files with 15 additions and 11 deletions

View File

@ -12,5 +12,5 @@ export const config = dotenv.config({
}).parsed; }).parsed;
// const config = useConfig(); // const config = useConfig();
// export const config = process.env; // export const config = process.env;
console.log('config', config); // console.log('config', config);
export const port = config.PORT || 4005; export const port = config.PORT || 4005;

View File

@ -7,7 +7,7 @@ const minioConfig = {
accessKey: config.MINIO_ACCESS_KEY, accessKey: config.MINIO_ACCESS_KEY,
secretKey: config.MINIO_SECRET_KEY, secretKey: config.MINIO_SECRET_KEY,
}; };
console.log('minioConfig', minioConfig); // console.log('minioConfig', minioConfig);
export const minioClient = new Client(minioConfig); export const minioClient = new Client(minioConfig);
export const bucketName = config.MINIO_BUCKET_NAME || 'resources'; export const bucketName = config.MINIO_BUCKET_NAME || 'resources';

View File

@ -134,6 +134,15 @@ router.post('/api/s1/resources/upload/chunk', async (req, res) => {
// Clean up the final file // Clean up the final file
fs.unlinkSync(finalFilePath); fs.unlinkSync(finalFilePath);
const downloadBase = '/api/s1/share';
const uploadResult = {
name: relativePath,
path: `${downloadBase}/${minioPath}`,
appKey,
version,
username,
};
if (!noCheckAppFiles) { if (!noCheckAppFiles) {
// Notify the app // Notify the app
const r = await app.call({ const r = await app.call({
@ -148,17 +157,11 @@ router.post('/api/s1/resources/upload/chunk', async (req, res) => {
}, },
}, },
}); });
const downloadBase = '/api/s1/share';
const data: any = { const data: any = {
code: r.code, code: r.code,
data: { data: {
app: r.body, app: r.body,
upload: [ upload: [uploadResult],
{
name: relativePath,
path: `${downloadBase}/${minioPath}`,
},
],
}, },
}; };
if (r.message) { if (r.message) {
@ -172,7 +175,7 @@ router.post('/api/s1/resources/upload/chunk', async (req, res) => {
res.end( res.end(
JSON.stringify({ JSON.stringify({
message: 'Chunk uploaded successfully', message: 'Chunk uploaded successfully',
data: { chunkIndex, totalChunks }, data: { chunkIndex, totalChunks, upload: [uploadResult] },
}), }),
); );
} }
@ -180,6 +183,7 @@ router.post('/api/s1/resources/upload/chunk', async (req, res) => {
res.writeHead(200, { 'Content-Type': 'application/json' }); res.writeHead(200, { 'Content-Type': 'application/json' });
res.end( res.end(
JSON.stringify({ JSON.stringify({
code: 200,
message: 'Chunk uploaded successfully', message: 'Chunk uploaded successfully',
data: { data: {
chunkIndex, chunkIndex,

@ -1 +1 @@
Subproject commit 60c5a986edd4add11b229b2d3c869dcdf32c0428 Subproject commit 162d4c72b409530c6789ea8b3efcc7963715bed8