Include Content-Disposition: attachment on some uploaded assets (#197)

This commit is contained in:
Mateusz Burzyński
2026-01-29 21:11:51 +00:00
committed by pullfrog[bot]
parent 943409c417
commit bb7e7584d4
2 changed files with 6 additions and 3 deletions
+3 -2
View File
@@ -143108,13 +143108,14 @@ function UploadFileTool(ctx) {
const error50 = await response.text(); const error50 = await response.text();
throw new Error(`failed to get upload URL: ${error50}`); throw new Error(`failed to get upload URL: ${error50}`);
} }
const { uploadUrl, publicUrl } = await response.json(); const { uploadUrl, publicUrl, contentDisposition } = await response.json();
const uploadResponse = await fetch(uploadUrl, { const uploadResponse = await fetch(uploadUrl, {
method: "PUT", method: "PUT",
headers: { headers: {
"Content-Type": contentType, "Content-Type": contentType,
// should be set automatically, but given this header is signed it's better to be explicit // should be set automatically, but given this header is signed it's better to be explicit
"Content-Length": String(contentLength) "Content-Length": String(contentLength),
...contentDisposition && { "Content-Disposition": contentDisposition }
}, },
body: buffer body: buffer
}); });
+3 -1
View File
@@ -44,9 +44,10 @@ export function UploadFileTool(ctx: ToolContext) {
throw new Error(`failed to get upload URL: ${error}`); throw new Error(`failed to get upload URL: ${error}`);
} }
const { uploadUrl, publicUrl } = (await response.json()) as { const { uploadUrl, publicUrl, contentDisposition } = (await response.json()) as {
uploadUrl: string; uploadUrl: string;
publicUrl: string; publicUrl: string;
contentDisposition?: string | undefined;
}; };
const uploadResponse = await fetch(uploadUrl, { const uploadResponse = await fetch(uploadUrl, {
@@ -55,6 +56,7 @@ export function UploadFileTool(ctx: ToolContext) {
"Content-Type": contentType, "Content-Type": contentType,
// should be set automatically, but given this header is signed it's better to be explicit // should be set automatically, but given this header is signed it's better to be explicit
"Content-Length": String(contentLength), "Content-Length": String(contentLength),
...(contentDisposition && { "Content-Disposition": contentDisposition }),
}, },
body: buffer, body: buffer,
}); });