export class FileInfoDto {
originalname: string;
encoding: string;
mimetype: string;
size: number;
destination: string;
filename: string;
path: string;
buffer: Buffer;
}
document
If options.withFileTypes is set to true, the resolved array will contain <fs.Dirent> objects.
async inspectionFindFile(destPath, list: FileInfoDto[]) {
try {
await fs
.readdirSync(destPath, { withFileTypes: true })
.forEach((file) => {
const filePath = `${destPath}/${file.name}`;
if (file.isDirectory()) {
this.inspectionFindFile(filePath, list);
} else {
const ext = path.extname(filePath).toLowerCase();
if (ext === '.png' || ext === '.jpg' || ext === '.jpge') {
list.push(
Builder(FileInfoDto)
.filename(file.name)
.originalname(file.name)
.path(path.join(filePath, file.name))
.build(),
);
}
}
});
return list;
} catch (e) {
this.logger.error(e.message);
return new throws(e.message);
}
}