controllers/imageController.js
/**
   * Finds image record in database matching object ID and image ID from the url parameters.
   * 
   * Reply is binary image data.
   * 
   * If the image is not found then response is 404.
   * 
   * @param {fastify.Request} req Fastify request instance.
   * @param {fastify.Reply} rep Fastify reply instance.
   */
Finds image record in database matching object ID and image ID from the url parameters.

Reply is binary image data.

If the image is not found then response is 404.

@param {fastify.Request} req Fastify request instance.
@param {fastify.Reply} rep Fastify reply instance.
Finds image record in database matching object ID and image ID from the url parameters . Reply is binary image data . If the image is not found then response is 404 . @param { fastify . Request } req Fastify request instance . @param { fastify . Reply } rep Fastify reply instance .
static async handleGetObjectImage(req, rep) {
    const image = await this.models.collectionsObjectImage.findOne({
      offset: req.params.imageId,
      where: {
        object_id: req.params.objectId,
        is_thumb: false
      }
    });
    if(image === null) {
      rep.code(404).send('Not found');
    } else {
      const imagePublicPath = `${Config.images.src}${image.imagePublicPath}`;
      const raw = await axios.get(imagePublicPath, {
        responseType: 'arraybuffer'
      });
      rep
        .code(200)
        .header('Content-type', raw.headers['content-type'])
        .send(Buffer.from(raw.data, 'binary'));
    }
  }
static async handleGetObjectImage ( req , rep ) { const image = await this . models . collectionsObjectImage . findOne ( { offset : req . params . imageId , where : { object_id : req . params . objectId , is_thumb : false } } ) ; if ( image === null ) { rep . code ( 404 ) . send ( 'Not found' ) ; } else { const imagePublicPath = ` ${ Config . images . src } ${ image . imagePublicPath } ` ; const raw = await axios . get ( imagePublicPath , { responseType : 'arraybuffer' } ) ; rep . code ( 200 ) . header ( 'Content-type' , raw . headers [ 'content-type' ] ) . send ( Buffer . from ( raw . data , 'binary' ) ) ; } }
Finds image record in database matching object ID and image ID from the url parameters.
Finds image record in database matching object ID and image ID from the url parameters .