Fixing an issue with images and REST queries, these traditionally have only come back as binary data to Budibase, but this isn't very useful, its very difficult to convert these into something that can be used. Instead we will now download images into temporary attachments as we do for other types with a real content-disposition.

This commit is contained in:
mike12345567 2024-05-17 14:01:43 +01:00
parent 8547b9b66e
commit ec2ec4014c
1 changed files with 9 additions and 0 deletions

View File

@ -23,6 +23,15 @@ export function getAttachmentHeaders(headers: Headers) {
} }
} }
} }
// for images which don't supply a content disposition, make one up, as binary
// data for images in REST responses isn't really useful, we should always download them
else if (contentType.startsWith("image/")) {
const format = contentType.split("/")[1]
return {
contentDisposition: `attachment; filename="image.${format}"`,
contentType,
}
}
return { contentDisposition, contentType } return { contentDisposition, contentType }
} }