Skip to content

Commit

Permalink
fix: return x-transformation options if provided (#539)
Browse files Browse the repository at this point in the history
  • Loading branch information
fenos authored Aug 23, 2024
1 parent 7f305da commit e416b7a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/storage/renderer/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Obj } from '@storage/schemas'
import { HeadRenderer } from './head'
import { FastifyRequest, FastifyReply } from 'fastify'
import { AssetResponse, RenderOptions } from './renderer'
import { ImageRenderer, TransformOptions } from '@storage/renderer/image'

/**
* HeadRenderer
Expand All @@ -15,6 +16,7 @@ export class InfoRenderer extends HeadRenderer {

return {
...headAsset,
transformations: ImageRenderer.applyTransformation(request.query as TransformOptions),
body: {
id: obj.id,
name: obj.name,
Expand Down Expand Up @@ -43,5 +45,9 @@ export class InfoRenderer extends HeadRenderer {
.header('Content-Length', data.metadata.contentLength)
.header('Last-Modified', data.metadata.lastModified?.toUTCString())
.header('CacheControl', data.metadata.cacheControl)

if (data.transformations && data.transformations.length > 0) {
response.header('X-Transformations', data.transformations.join(','))
}
}
}

0 comments on commit e416b7a

Please sign in to comment.