File tree Expand file tree Collapse file tree
apps/sim/app/api/workspaces/[id]/files/inline Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,6 +60,19 @@ describe('GET /api/workspaces/[id]/files/inline', () => {
6060 } )
6161 } )
6262
63+ it ( 'derives a renderable image type when storage recorded generic bytes' , async ( ) => {
64+ mockReadInline . mockResolvedValue ( {
65+ file : { name : 'photo.png' , type : 'application/octet-stream' , size : PNG . length } ,
66+ stream : new Blob ( [ new Uint8Array ( PNG ) ] ) . stream ( ) ,
67+ contentAddressed : true ,
68+ } )
69+
70+ const res = await GET ( req ( 'key=workspace%2Fws-1%2Fphoto.png' ) , params )
71+
72+ expect ( res . headers . get ( 'Content-Type' ) ) . toBe ( 'image/png' )
73+ expect ( res . headers . get ( 'Content-Disposition' ) ) . toBe ( 'inline; filename="photo.png"' )
74+ } )
75+
6376 /**
6477 * A storage key names one object and a content write never rewrites one, so these bytes can never
6578 * change. Revalidating them meant re-downloading every embedded image on every open — a document is
Original file line number Diff line number Diff line change 44 internalRateLimits ,
55 internalSessionAuth ,
66} from '@/lib/api/server/routes'
7+ import { resolveEffectiveMimeType } from '@/lib/uploads/utils/file-utils'
78import { internalFileErrorPolicies } from '@/lib/workspace-files/api'
89import { readWorkspaceInlineFile } from '@/lib/workspace-files/application/read-workspace-inline-file'
910import { encodeFilenameForHeader , getSecureFileHeaders } from '@/app/api/files/utils'
@@ -48,7 +49,7 @@ export const GET = defineInternalBinaryRoute({
4849 } ) ,
4950 useCase : readWorkspaceInlineFile ,
5051 present : ( { file, stream, contentAddressed } ) => {
51- const secure = getSecureFileHeaders ( file . name , file . type )
52+ const secure = getSecureFileHeaders ( file . name , resolveEffectiveMimeType ( file . type , file . name ) )
5253 const headers = new Headers ( {
5354 'Content-Type' : secure . contentType ,
5455 'Content-Disposition' : `${ secure . disposition } ; ${ encodeFilenameForHeader ( file . name ) } ` ,
You can’t perform that action at this time.
0 commit comments