Skip to content

Commit

Permalink
chore: added debugs for file processing
Browse files Browse the repository at this point in the history
  • Loading branch information
raaymax committed Jan 29, 2024
1 parent 2a7ad3c commit 6ec9e39
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/server/src/interfaces/http/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ async function downloadFile(req, res) {
'Content-Type': file.contentType,
'Content-Disposition': `inline; filename="${file.metadata.filename}"`,
});
file.getStream().pipe(res);
file.getStream().pipe(res).on('error', (err) => {
// eslint-disable-next-line no-console
console.error(err);
res.status(500).send({ errorCode: 'INTERNAL_SERVER_ERROR' });
});
} catch (err) {
if (err.code === 'ENOTFOUND') {
return res.status(404).send({ errorCode: 'RESOURCE_NOT_FOUND' });
Expand Down
4 changes: 3 additions & 1 deletion packages/storage/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class Files implements Storage {
throw new Error('File not found');
}
const t = sharp().resize(width, height);
await this.service.upload(file.getStream().pipe(t), {
await this.service.upload(file.getStream().pipe(t).on('error', (err) => {
throw err;
}), {
id: targetId,
originalname: file.metadata.filename,
mimetype: file.contentType,
Expand Down

0 comments on commit 6ec9e39

Please sign in to comment.