Skip to content

Commit

Permalink
fix(api): support mosaic without preview (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba authored Aug 12, 2024
1 parent da12603 commit f4fb54b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions api/router/mosaic_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,22 +167,27 @@ func (r *MosaicRouter) DownloadTile(c *fiber.Ctx) error {
return err
}
}
ext := c.Params("ext")
buf, snapshot, err := r.mosaicSvc.DownloadTileBuffer(id, service.MosaicDownloadTileOptions{
ZoomLevel: int(zoomLevel),
Row: int(row),
Col: int(col),
Ext: ext,
Ext: c.Params("ext"),
}, userID)
if err != nil {
return err
}
if strings.TrimPrefix(filepath.Ext(snapshot.GetPreview().Key), ".") != c.Params("ext") {
var extension string
if snapshot.GetPreview() != nil {
extension = filepath.Ext(snapshot.GetPreview().Key)
} else {
extension = filepath.Ext(snapshot.GetOriginal().Key)
}
if strings.TrimPrefix(extension, ".") != c.Params("ext") {
return errorpkg.NewS3ObjectNotFoundError(nil)
}
b := buf.Bytes()
c.Set("Content-Type", infra.DetectMimeFromBytes(b))
c.Set("Content-Disposition", fmt.Sprintf("filename=\"tile%s\"", ext))
c.Set("Content-Disposition", fmt.Sprintf("filename=\"tile%s\"", c.Params("ext")))
return c.Send(b)
}

Expand Down

0 comments on commit f4fb54b

Please sign in to comment.