upload data change
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user