mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-12-03 16:10:37 +00:00
fix: show gif and upper-case image keys in object storage as images
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
d03dca74fe
commit
270909e26e
@@ -59,6 +59,7 @@
|
||||
displayDate,
|
||||
displaySize,
|
||||
emptyString,
|
||||
isS3ImageKey,
|
||||
parseS3Object,
|
||||
sendUserToast,
|
||||
type S3Object,
|
||||
@@ -871,11 +872,7 @@
|
||||
}
|
||||
if (fileMetadata) {
|
||||
fileMetadata.mimeType =
|
||||
((fileKey.endsWith('.png') ||
|
||||
fileKey.endsWith('.jpg') ||
|
||||
fileKey.endsWith('.jpeg') ||
|
||||
fileKey.endsWith('.webp')) &&
|
||||
'Image') ||
|
||||
(isS3ImageKey(fileKey) && 'Image') ||
|
||||
(fileKey.endsWith('.pdf') && 'PDF') ||
|
||||
filePreview.contentType
|
||||
}
|
||||
|
||||
@@ -391,7 +391,7 @@ export const showImageTool: SessionTool<{}> = {
|
||||
}
|
||||
const s3 = parsed.s3!
|
||||
if (!isS3ImageKey(s3.s3)) {
|
||||
return `"${s3.s3}" is not an image the viewer can show (png, jpeg or webp).`
|
||||
return `"${s3.s3}" is not an image the viewer can show (png, jpeg, gif or webp).`
|
||||
}
|
||||
openImage(
|
||||
{ kind: 'url', url: s3ImagePreviewUrl(workspace, s3) },
|
||||
|
||||
@@ -1943,11 +1943,10 @@ export function parseS3Object(s3Object: S3Object): { s3: string; storage?: strin
|
||||
return { storage: match?.[1] || undefined, s3: match?.[2] ?? '' }
|
||||
}
|
||||
|
||||
const S3_IMAGE_EXTENSIONS = ['.png', '.jpeg', '.jpg', '.webp']
|
||||
|
||||
/** Whether a result's S3 object renders as an image. */
|
||||
/** Whether a result's S3 object renders as an image: the extensions `load_image_preview` serves
|
||||
* with an image type, in any case, as the AI session's `read_s3_file` reads them. */
|
||||
export function isS3ImageKey(key: string): boolean {
|
||||
return S3_IMAGE_EXTENSIONS.some((ext) => key.endsWith(ext))
|
||||
return /\.(png|jpe?g|gif|webp)$/i.test(key)
|
||||
}
|
||||
|
||||
/** The workspace's preview URL for an S3 image a job returned. */
|
||||
|
||||
Reference in New Issue
Block a user