mirror of
https://github.com/laosb/ghos3.git
synced 2025-04-30 23:51:08 +00:00
Handle NoSuchKey error gracefully
This commit is contained in:
parent
ac6e5bc277
commit
91c131a72d
1 changed files with 7 additions and 2 deletions
|
@ -196,12 +196,17 @@ class S3Storage extends StorageBase {
|
||||||
const stream = output.Body as Readable
|
const stream = output.Body as Readable
|
||||||
stream.pipe(res)
|
stream.pipe(res)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
res.status(404)
|
if (err.name === 'NoSuchKey') {
|
||||||
next(err)
|
res.status(404).send('Image not found');
|
||||||
|
} else {
|
||||||
|
res.status(500);
|
||||||
|
next(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async read(options: ReadOptions = { path: '' }) {
|
async read(options: ReadOptions = { path: '' }) {
|
||||||
let path = (options.path || '').replace(/\/$|\\$/, '')
|
let path = (options.path || '').replace(/\/$|\\$/, '')
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue