Accept zip file from training job

This commit is contained in:
mmcwilliams 2023-11-29 12:47:20 -05:00
parent 226c972020
commit cabd7f3415
3 changed files with 11 additions and 11 deletions

10
dist/index.js vendored
View File

@ -39,7 +39,7 @@ function fileFilter(req, file, cb) {
}
}
const uploadZip = (0, multer_1.default)({ storage, fileFilter });
const uploadOnnx = (0, multer_1.default)({ storage });
const uploadOnnx = (0, multer_1.default)({ storage, fileFilter });
app.use(body_parser_1.default.json());
app.use(body_parser_1.default.urlencoded({ extended: true }));
function hash(path) {
@ -271,10 +271,10 @@ app.post('/job/:id', uploadOnnx.single('model'), async (req, res, next) => {
req.setTimeout(0);
if (typeof req.file === 'undefined' || req.file === null) {
console.error('No file in upload');
return next('ERROR: Please model as ONNX file');
return next('ERROR: Please model as zip file');
}
id = req.params.id;
filePath = (0, path_1.join)(data, `${id}.onnx`);
filePath = (0, path_1.join)(data, `${id}.zip`);
if (typeof req.body.meta !== 'undefined') {
meta = req.body.meta;
}
@ -333,7 +333,7 @@ app.get('/model/:id', async (req, res, next) => {
return next('Invalid request');
}
id = req.params.id;
filePath = (0, path_1.join)(data, `${id}.onnx`);
filePath = (0, path_1.join)(data, `${id}.zip`);
try {
fileExists = await exists(filePath);
}
@ -353,7 +353,7 @@ app.get('/model/:id', async (req, res, next) => {
return next(`Error getting job ${id}`);
}
mimeType = (0, mime_1.getType)(filePath);
res.setHeader('Content-disposition', `attachment; filename=${fileName}.onnx`);
res.setHeader('Content-disposition', `attachment; filename=${fileName}.zip`);
res.setHeader('Content-type', mimeType);
stream = (0, fs_1.createReadStream)(filePath);
stream.pipe(res);

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -39,7 +39,7 @@ function fileFilter (req: any, file: any, cb: any) {
}
const uploadZip : any = multer({ storage, fileFilter });
const uploadOnnx : any = multer({ storage });
const uploadOnnx : any = multer({ storage, fileFilter });
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
@ -275,11 +275,11 @@ app.post('/job/:id', uploadOnnx.single('model'), async (req : Request, res : Res
if (typeof req.file === 'undefined' || req.file === null) {
console.error('No file in upload');
return next('ERROR: Please model as ONNX file');
return next('ERROR: Please model as zip file');
}
id = req.params.id;
filePath = join(data, `${id}.onnx`);
filePath = join(data, `${id}.zip`);
if (typeof req.body.meta !== 'undefined') {
meta = req.body.meta;
}
@ -345,7 +345,7 @@ app.get('/model/:id', async (req : Request, res: Response, next : NextFunction)
}
id = req.params.id;
filePath = join(data, `${id}.onnx`);
filePath = join(data, `${id}.zip`);
try {
fileExists = await exists(filePath);
} catch (err) {
@ -364,7 +364,7 @@ app.get('/model/:id', async (req : Request, res: Response, next : NextFunction)
}
mimeType = getType(filePath);
res.setHeader('Content-disposition', `attachment; filename=${fileName}.onnx`);
res.setHeader('Content-disposition', `attachment; filename=${fileName}.zip`);
res.setHeader('Content-type', mimeType);
stream = createReadStream(filePath);