upload data change

This commit is contained in:
2025-03-29 20:56:03 +08:00
parent d8d78d184b
commit 80d16b5f76
5 changed files with 135 additions and 411 deletions

View File

@@ -23,6 +23,7 @@ router.post('/api/s1/resources/upload/chunk', async (req, res) => {
if (!tokenUser) return;
const url = new URL(req.url || '', 'http://localhost');
const share = !!url.searchParams.get('public');
const noCheckAppFiles = !!url.searchParams.get('noCheckAppFiles');
// 使用 formidable 解析 multipart/form-data
const form = new IncomingForm({
multiples: false, // 改为单文件上传
@@ -133,34 +134,48 @@ router.post('/api/s1/resources/upload/chunk', async (req, res) => {
// Clean up the final file
fs.unlinkSync(finalFilePath);
// Notify the app
const r = await app.call({
path: 'app',
key: 'detect-version-list',
payload: {
token: token,
data: {
appKey,
version,
username,
if (!noCheckAppFiles) {
// Notify the app
const r = await app.call({
path: 'app',
key: 'detect-version-list',
payload: {
token: token,
data: {
appKey,
version,
username,
},
},
},
});
const downloadBase = '/api/s1/share';
const data: any = {
code: r.code,
data: {
app: r.body,
resource: `${downloadBase}/${minioPath}`,
},
};
if (r.message) {
data.message = r.message;
});
const downloadBase = '/api/s1/share';
const data: any = {
code: r.code,
data: {
app: r.body,
upload: [
{
name: relativePath,
path: `${downloadBase}/${minioPath}`,
},
],
},
};
if (r.message) {
data.message = r.message;
}
console.log('upload data', data);
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify(data));
} else {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(
JSON.stringify({
message: 'Chunk uploaded successfully',
data: { chunkIndex, totalChunks },
}),
);
}
console.log('upload data', data);
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify(data));
} else {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(