update: room picture upload and hospital logo upload
This commit is contained in:
@ -318,18 +318,8 @@ export class RoomController {
|
||||
format: "binary",
|
||||
description: "Image file (max 1MB, jpg/png/webp)"
|
||||
},
|
||||
path: {
|
||||
type: "string",
|
||||
description: 'File path',
|
||||
default: 'uploads/room-picture'
|
||||
},
|
||||
application: {
|
||||
type: "string",
|
||||
description: 'Application name',
|
||||
default: 'saude'
|
||||
}
|
||||
},
|
||||
required: ["file", "path", "application"]
|
||||
required: ["file"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -338,13 +328,13 @@ export class RoomController {
|
||||
try {
|
||||
// Validation schema
|
||||
const schema = Joi.object().keys({
|
||||
path: Joi.string().label('File Path'),
|
||||
application: Joi.string().label('Application'),
|
||||
// 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) {
|
||||
@ -366,9 +356,9 @@ export class RoomController {
|
||||
}
|
||||
|
||||
// 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/room-picture/';
|
||||
// if (param.path == undefined || param.path == null) param.path = 'uploads/room-picture/';
|
||||
|
||||
// Generate unique filename
|
||||
const ext = file.name.split('.');
|
||||
@ -383,7 +373,7 @@ export class RoomController {
|
||||
// md5: file.md5
|
||||
};
|
||||
|
||||
const folder_path = param.path;
|
||||
const folder_path = 'uploads/room-picture/';
|
||||
const file_path = path.join(folder_path, name);
|
||||
|
||||
// Create directory if it doesn't exist
|
||||
|
||||
Reference in New Issue
Block a user