update: room picture upload and hospital logo upload
This commit is contained in:
@ -176,18 +176,8 @@ export class HospitalInformationController {
|
||||
format: "binary",
|
||||
description: "Image file (max 1MB, jpg/png/webp)"
|
||||
},
|
||||
path: {
|
||||
type: "string",
|
||||
description: 'File path',
|
||||
default: 'uploads/hospital-logo'
|
||||
},
|
||||
application: {
|
||||
type: "string",
|
||||
description: 'Application name',
|
||||
default: 'saude'
|
||||
}
|
||||
},
|
||||
required: ["file", "path", "application"]
|
||||
required: ["file"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -195,14 +185,14 @@ export class HospitalInformationController {
|
||||
*/
|
||||
try {
|
||||
// Validation schema
|
||||
const schema = Joi.object().keys({
|
||||
path: Joi.string().label('File Path'),
|
||||
application: Joi.string().label('Application'),
|
||||
});
|
||||
// const schema = Joi.object().keys({
|
||||
// path: Joi.string().label('File Path'),
|
||||
// application: Joi.string().label('Application'),
|
||||
// });
|
||||
|
||||
log.info("body", req.body);
|
||||
|
||||
const param: { path: string, application: string } = await schema.validateAsync(req.body);
|
||||
// const param: { path: string, application: string } = await schema.validateAsync(req.body);
|
||||
|
||||
// Check if file exists
|
||||
if (!req.files || !req.files.file) {
|
||||
@ -224,9 +214,9 @@ export class HospitalInformationController {
|
||||
}
|
||||
|
||||
// Normalize path
|
||||
param.path = param.path[param.path.length - 1] !== '/' ? param.path + '/' : param.path;
|
||||
// param.path = param.path[param.path.length - 1] !== '/' ? param.path + '/' : param.path;
|
||||
|
||||
if (param.path == undefined || param.path == null) param.path = 'uploads/hospital-logo/';
|
||||
// if (param.path == undefined || param.path == null) param.path = 'uploads/hospital-logo/';
|
||||
|
||||
// Generate unique filename
|
||||
const ext = file.name.split('.');
|
||||
@ -241,7 +231,7 @@ export class HospitalInformationController {
|
||||
// md5: file.md5
|
||||
};
|
||||
|
||||
const folder_path = param.path;
|
||||
const folder_path ='uploads/hospital-logo/';
|
||||
const file_path = path.join(folder_path, name);
|
||||
|
||||
// Create directory if it doesn't exist
|
||||
|
||||
Reference in New Issue
Block a user