tango-app-api-trax 3.7.13-qid-halfshutter-14 → 3.7.13-qid-halfshutter-16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -2629,7 +2629,7 @@ export async function getRunAIList( req, res ) {
|
|
|
2629
2629
|
try {
|
|
2630
2630
|
let getChecklistDetails = await CLconfig.find( { publish: true, ...( req.query.clientId && { client_id: req.query.clientId } ) } );
|
|
2631
2631
|
if ( !getChecklistDetails.length ) {
|
|
2632
|
-
return res.
|
|
2632
|
+
return res.sendSuccess( [] );
|
|
2633
2633
|
}
|
|
2634
2634
|
let runAIList=[];
|
|
2635
2635
|
await Promise.all( getChecklistDetails.map( async ( check ) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logger, signedUrl, fileUpload, getOtp, sendEmailWithSES, getUuid, insertOpenSearchData } from 'tango-app-api-middleware';
|
|
1
|
+
import { logger, signedUrl, fileUpload, getOtp, sendEmailWithSES, getUuid, insertOpenSearchData, listFileByPath, getObject, deleteFiles } from 'tango-app-api-middleware';
|
|
2
2
|
import * as processedchecklist from '../services/processedchecklist.services.js';
|
|
3
3
|
import * as processedtask from '../services/processedTaskList.service.js';
|
|
4
4
|
import * as PCLconfig from '../services/processedchecklistconfig.services.js';
|
|
@@ -4389,3 +4389,57 @@ export async function questionListV1( req, res ) {
|
|
|
4389
4389
|
}
|
|
4390
4390
|
}
|
|
4391
4391
|
|
|
4392
|
+
export async function chunkUpload( req, res ) {
|
|
4393
|
+
try {
|
|
4394
|
+
const { chunkIndex, totalChunks } = req.body;
|
|
4395
|
+
if ( chunkIndex === undefined || !totalChunks || !req.files || !req.files.answerImage ) {
|
|
4396
|
+
return res.status( 400 ).json( { error: 'Missing required params or file.' } );
|
|
4397
|
+
}
|
|
4398
|
+
const chunkNum = Number( chunkIndex );
|
|
4399
|
+
const chunkTotal = Number( totalChunks );
|
|
4400
|
+
const chunkFile = req.files.answerImage;
|
|
4401
|
+
const chunkKey = `traxVideoChunks/${req.user._id}/${chunkNum}`;
|
|
4402
|
+
let bucket;
|
|
4403
|
+
try {
|
|
4404
|
+
bucket = JSON.parse( process.env.BUCKET )?.sop;
|
|
4405
|
+
} catch {
|
|
4406
|
+
return res.sendError( 'Bucket config error', 500 );
|
|
4407
|
+
}
|
|
4408
|
+
await fileUpload( {
|
|
4409
|
+
fileName: '',
|
|
4410
|
+
Key: chunkKey,
|
|
4411
|
+
Bucket: bucket,
|
|
4412
|
+
ContentType: chunkFile.mimetype,
|
|
4413
|
+
body: chunkFile.data,
|
|
4414
|
+
} );
|
|
4415
|
+
if ( chunkNum < chunkTotal ) {
|
|
4416
|
+
return res.sendSuccess( { message: 'Chunk uploaded to S3', chunkIndex: chunkNum } );
|
|
4417
|
+
}
|
|
4418
|
+
const prefix = `traxVideoChunks/${req.user._id}/`;
|
|
4419
|
+
const s3FilesResp = await listFileByPath( { Bucket: bucket, file_path: prefix, MaxKeys: chunkTotal } );
|
|
4420
|
+
const chunkObjs = s3FilesResp?.data || [];
|
|
4421
|
+
chunkObjs.sort( ( a, b ) => {
|
|
4422
|
+
const ai = Number( a.Key.split( '/' ).pop() );
|
|
4423
|
+
const bi = Number( b.Key.split( '/' ).pop() );
|
|
4424
|
+
return ai - bi;
|
|
4425
|
+
} );
|
|
4426
|
+
const buffers = [];
|
|
4427
|
+
for ( const obj of chunkObjs ) {
|
|
4428
|
+
const s3Obj = await getObject( { Bucket: bucket, Key: obj.Key } );
|
|
4429
|
+
buffers.push( Buffer.from( s3Obj.Body ) );
|
|
4430
|
+
}
|
|
4431
|
+
const finalBuffer = Buffer.concat( buffers );
|
|
4432
|
+
try {
|
|
4433
|
+
await deleteFiles( bucket, prefix );
|
|
4434
|
+
} catch ( e ) {}
|
|
4435
|
+
req.files.answerImage = {
|
|
4436
|
+
data: finalBuffer,
|
|
4437
|
+
name: chunkFile.name,
|
|
4438
|
+
mimetype: chunkFile.mimetype,
|
|
4439
|
+
};
|
|
4440
|
+
return uploadAnswerImage( req, res );
|
|
4441
|
+
} catch ( e ) {
|
|
4442
|
+
logger.error( { functionName: 'chunkUpload', error: e } );
|
|
4443
|
+
return res.sendError( e, 500 );
|
|
4444
|
+
}
|
|
4445
|
+
}
|
|
@@ -29,5 +29,6 @@ mobileRouter
|
|
|
29
29
|
.post( '/checkUpdateVersion', mobileController.checkVersion )
|
|
30
30
|
.post( '/checkUpdateVersionv1', mobileController.checkVersionV1 )
|
|
31
31
|
.post( '/checkClientConfig', isAllowedSessionHandler, mobileController.clientConfig )
|
|
32
|
-
.post( '/updatePlanoStatus', isAllowedSessionHandler, mobileController.updatePlanoStatus )
|
|
32
|
+
.post( '/updatePlanoStatus', isAllowedSessionHandler, mobileController.updatePlanoStatus )
|
|
33
|
+
.post( '/chunkUpload', isAllowedSessionHandler, mobileController.chunkUpload );
|
|
33
34
|
|