|
|
@ -60,14 +60,12 @@ export class AttachmentsController { |
|
|
|
// This route will match any URL that starts with
|
|
|
|
// This route will match any URL that starts with
|
|
|
|
async fileRead(@Param('filename') filename: string, @Response() res) { |
|
|
|
async fileRead(@Param('filename') filename: string, @Response() res) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const { img, type } = await this.attachmentsService.fileRead({ |
|
|
|
const file = await this.attachmentsService.getFile({ |
|
|
|
path: path.join('nc', 'uploads', filename), |
|
|
|
path: path.join('nc', 'uploads', filename), |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
res.writeHead(200, { 'Content-Type': type }); |
|
|
|
res.sendFile(file.path); |
|
|
|
res.end(img, 'binary'); |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
console.log(e); |
|
|
|
|
|
|
|
res.status(404).send('Not found'); |
|
|
|
res.status(404).send('Not found'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -82,7 +80,7 @@ export class AttachmentsController { |
|
|
|
@Response() res, |
|
|
|
@Response() res, |
|
|
|
) { |
|
|
|
) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const { img, type } = await this.attachmentsService.fileRead({ |
|
|
|
const file = await this.attachmentsService.getFile({ |
|
|
|
path: path.join( |
|
|
|
path: path.join( |
|
|
|
'nc', |
|
|
|
'nc', |
|
|
|
param1, |
|
|
|
param1, |
|
|
@ -92,8 +90,7 @@ export class AttachmentsController { |
|
|
|
), |
|
|
|
), |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
res.writeHead(200, { 'Content-Type': type }); |
|
|
|
res.sendFile(file.path); |
|
|
|
res.end(img, 'binary'); |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
res.status(404).send('Not found'); |
|
|
|
res.status(404).send('Not found'); |
|
|
|
} |
|
|
|
} |
|
|
@ -104,11 +101,11 @@ export class AttachmentsController { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const fpath = await PresignedUrl.getPath(`dltemp/${param}`); |
|
|
|
const fpath = await PresignedUrl.getPath(`dltemp/${param}`); |
|
|
|
|
|
|
|
|
|
|
|
const { img } = await this.attachmentsService.fileRead({ |
|
|
|
const file = await this.attachmentsService.getFile({ |
|
|
|
path: path.join('nc', 'uploads', fpath), |
|
|
|
path: path.join('nc', 'uploads', fpath), |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
res.sendFile(img); |
|
|
|
res.sendFile(file.path); |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
res.status(404).send('Not found'); |
|
|
|
res.status(404).send('Not found'); |
|
|
|
} |
|
|
|
} |
|
|
|