Fix image uploads using the wrong format (#2380)
* fix(app): preserve image attachment MIME types Image intake discarded clipboard and desktop path metadata, then guessed JPEG when a later file object had no type. Resolve MIME once at the platform boundary and require it downstream. * fix(app): honor native picker MIME metadata
This commit is contained in:
@@ -92,7 +92,7 @@ describe("collectImageFilesFromClipboardData", () => {
|
||||
],
|
||||
});
|
||||
|
||||
expect(files).toEqual([imagePng]);
|
||||
expect(files).toEqual([{ file: imagePng, mimeType: "image/png" }]);
|
||||
});
|
||||
|
||||
it("ignores SVG clipboard files", () => {
|
||||
@@ -127,7 +127,10 @@ describe("filesToImageAttachments", () => {
|
||||
type: "",
|
||||
});
|
||||
|
||||
const attachments = await filesToImageAttachments([pngFile, typeLessFile]);
|
||||
const attachments = await filesToImageAttachments([
|
||||
{ file: pngFile, mimeType: "image/png" },
|
||||
{ file: typeLessFile, mimeType: "image/png" },
|
||||
]);
|
||||
|
||||
expect(attachments).toEqual([
|
||||
{
|
||||
@@ -141,7 +144,7 @@ describe("filesToImageAttachments", () => {
|
||||
},
|
||||
{
|
||||
id: "att-2",
|
||||
mimeType: "image/jpeg",
|
||||
mimeType: "image/png",
|
||||
storageType: "web-indexeddb",
|
||||
storageKey: "att-2",
|
||||
fileName: "second",
|
||||
@@ -156,7 +159,7 @@ describe("filesToImageAttachments", () => {
|
||||
type: "image/png",
|
||||
});
|
||||
|
||||
const [attachment] = await filesToImageAttachments([large]);
|
||||
const [attachment] = await filesToImageAttachments([{ file: large, mimeType: "image/png" }]);
|
||||
|
||||
expect(attachment?.storageType).toBe("web-indexeddb");
|
||||
expect(attachment?.byteSize).toBe(4 * 1024 * 1024);
|
||||
|
||||
Reference in New Issue
Block a user