Repository for the Bootcamp 23.1 challenge
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

30 lines
728 B

const dbAstro = _db.get('astro', _req.getString('uid'))
if (dbAstro) {
const dbAstroImageName = dbAstro.getString('image')
//_log.info( dbAstroImageName );
const storageAstroImageFile =
_storage.database(
'astro',
'image',
dbAstroImageName
)
switch (storageAstroImageFile.extension()){
case 'jpg':
_header.contentTypeJPG()
break;
case 'png':
_header.contentTypePNG()
break;
default:
_error.fatal(`Invalid image extension ${storageAstroImageFile.extension()}`)
}
_header.noCache()
_out.copy(storageAstroImageFile.inputStream())
} else {
_header.status(404)
_out.json(
_val.map()
.set("error", "astro-image-not-found")
)
}