Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(desktop): paste images into feedback (#104073)

Dylan Martin3ff522fa6d7b
diff --git a/products/desktop/docs/FEEDBACK.md b/products/desktop/docs/FEEDBACK.md
index 1e1dd58d6317..36d44f3ec1fd 100644
--- a/products/desktop/docs/FEEDBACK.md
+++ b/products/desktop/docs/FEEDBACK.md
@@ -9,7 +9,7 @@ The form sends one authenticated request to the Desktop feedback endpoint. The e
The endpoint accepts an optional `feedback_type`: `bug`, `feature`, or `general`. The survey event stores this value. Older app versions can omit this field.
-The app captures the current window before the form opens. The screenshot can be reviewed and stays off until selected. People can also attach up to two images. Recent app logs can be reviewed while they stay off, and are sent only when selected.
+The app captures the current window before the form opens. The screenshot can be reviewed and stays off until selected. People can attach up to two images with **Attach images** or paste them into the message. Both methods use the same image checks and limit. Image previews open after attachment, and images can be removed before sending. Text paste still works. If another image is still loading, the form asks the user to wait and paste again. Files without a MIME type use their image signature; files with an incorrect or unsupported format are rejected. Recent app logs can be reviewed while they stay off, and are sent only when selected.
Selected screenshots and images are stored in PostHog's internal media project, not the project selected in Desktop. The survey response contains authenticated image links instead of image data. Only people with access to the internal feedback project can open them, and the public media route returns `404`. Links stop working after 30 days, and a daily cleanup removes the stored media. If the response fails, the endpoint removes the new media. The feedback modal is excluded from Session Replay, so previews and logs do not enter the recording.
diff --git a/products/desktop/packages/ui/src/features/feedback/FeedbackAttachments.tsx b/products/desktop/packages/ui/src/features/feedback/FeedbackAttachments.tsx
index 4d5592fb8f52..dbf67ebf2908 100644
--- a/products/desktop/packages/ui/src/features/feedback/FeedbackAttachments.tsx
+++ b/products/desktop/packages/ui/src/features/feedback/FeedbackAttachments.tsx
@@ -8,20 +8,15 @@ import {
Text,
Textarea,
} from "@posthog/quill";
-import { toast } from "@posthog/ui/primitives/toast";
import {
- type ChangeEvent,
type Dispatch,
type ReactNode,
type SetStateAction,
+ useEffect,
useRef,
useState,
} from "react";
-import {
- type FeedbackImage,
- MAX_FEEDBACK_IMAGE_COUNT,
- readFeedbackImage,
-} from "./feedbackImages";
+import { type FeedbackImage, MAX_FEEDBACK_IMAGE_COUNT } from "./feedbackImages";
export interface FeedbackAttachmentsValue {
includeScreenshot: boolean;
@@ -37,6 +32,7 @@ interface FeedbackAttachmentsProps {
value: FeedbackAttachmentsValue;
onChange: Dispatch<SetStateAction<FeedbackAttachmentsValue>>;
contextClient: IFeedbackContext;
+ onImageFiles: (files: File[]) => Promise<void>;
}
function AttachmentRow({ children }: { children: ReactNode }) {
@@ -78,6 +74,7 @@ export function FeedbackAttachments({
value,
onChange,
contextClient,
+ onImageFiles,
}: FeedbackAttachmentsProps) {
const [visibleAttachment, setVisibleAttachment] = useState<
"screenshot" | "logs" | "images" | null
@@ -86,6 +83,10 @@ export function FeedbackAttachments({
const imageInputRef = useRef<HTMLInputElement>(null);
const logsRequestRef = useRef(0);
+ useEffect(() => {
+ if (value.images.length > 0) setVisibleAttachment("images");
+ }, [value.images.length]);
+
const loadLogs = async (
includeWhenLoaded: boolean,
): Promise<string | null> => {
@@ -144,46 +145,6 @@ export function FeedbackAttachments({
setVisibleAttachment("logs");
};
- const handleImageSelect = async (event: ChangeEvent<HTMLInputElement>) => {
- const selectedFiles = Array.from(event.currentTarget.files ?? []);
- event.currentTarget.value = "";
- const availableSlots = MAX_FEEDBACK_IMAGE_COUNT - value.images.length;
- if (selectedFiles.length > availableSlots) {
- toast.warning(`You can attach up to ${MAX_FEEDBACK_IMAGE_COUNT} images.`);
- }
-
- onChange((current) => ({ ...current, imagesLoading: true }));
- try {
- const nextImages = await Promise.all(
- selectedFiles.slice(0, availableSlots).map(async (file) => {
- try {
- return await readFeedbackImage(file);
- } catch (error) {
- toast.error(
- error instanceof Error
- ? error.message
- : "Could not attach this image.",
- );
- return null;
- }
- }),
- );
- onChange((current) => ({
- ...current,
- images: [
- ...current.images,
- ...nextImages.filter(
- (image): image is FeedbackImage =>
- image !== null &&
- !current.images.some((existing) => existing.id === image.id),
- ),
- ].slice(0, MAX_FEEDBACK_IMAGE_COUNT),
- }));
- } finally {
- onChange((current) => ({ ...current, imagesLoading: false }));
- }
- };
-
return (
<div className="mt-1 flex flex-col border-gray-6 border-y py-1">
<AttachmentRow>
@@ -284,7 +245,11 @@ export function FeedbackAttachments({
multiple
aria-label="Choose feedback images"
className="hidden"
- onChange={(event) => void handleImageSelect(event)}
+ onChange={(event) => {
+ const files = Array.from(event.currentTarget.files ?? []);
+ event.currentTarget.value = "";
+ void onImageFiles(files);
+ }}
/>
<div className="mt-2">
<AttachmentRow>
diff --git a/products/desktop/packages/ui/src/features/feedback/FeedbackModal.test.tsx b/products/desktop/packages/ui/src/features/feedback/FeedbackModal.test.tsx
index 8a8b79e038b4..35d010359fd8 100644
--- a/products/desktop/packages/ui/src/features/feedback/FeedbackModal.test.tsx
+++ b/products/desktop/packages/ui/src/features/feedback/FeedbackModal.test.tsx
@@ -1,22 +1,28 @@
import type { FeedbackSubmissionInput } from "@posthog/platform/feedback-context";
-import { render, screen, waitFor } from "@testing-library/react";
+import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
-const { captureException, getAnalyticsSessionId, toastError, toastSuccess } =
- vi.hoisted(() => ({
- captureException: vi.fn(),
- getAnalyticsSessionId: vi.fn(),
- toastError: vi.fn(),
- toastSuccess: vi.fn(),
- }));
+const {
+ captureException,
+ getAnalyticsSessionId,
+ toastError,
+ toastSuccess,
+ toastWarning,
+} = vi.hoisted(() => ({
+ captureException: vi.fn(),
+ getAnalyticsSessionId: vi.fn(),
+ toastError: vi.fn(),
+ toastSuccess: vi.fn(),
+ toastWarning: vi.fn(),
+}));
vi.mock("@posthog/ui/shell/analytics", () => ({
captureException,
getAnalyticsSessionId,
}));
vi.mock("@posthog/ui/primitives/toast", () => ({
- toast: { error: toastError, success: toastSuccess, warning: vi.fn() },
+ toast: { error: toastError, success: toastSuccess, warning: toastWarning },
}));
vi.mock("@posthog/ui/router/useAppView", () => ({
getAppViewSnapshot: () => ({ type: "task-detail", taskId: "task-123" }),
@@ -24,6 +30,10 @@ vi.mock("@posthog/ui/router/useAppView", () => ({
import { FeedbackModal, type FeedbackModalMode } from "./FeedbackModal";
+const pngBytes = new Uint8Array([
+ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
+]);
+
const readRecentLogs = vi.fn<() => Promise<string | null>>();
const captureScreenshot = vi.fn<() => Promise<string | null>>();
const submitFeedback =
@@ -73,6 +83,7 @@ describe("FeedbackModal", () => {
submitFeedback.mockResolvedValue();
toastError.mockReset();
toastSuccess.mockReset();
+ toastWarning.mockReset();
});
afterEach(() => {
@@ -196,72 +207,217 @@ describe("FeedbackModal", () => {
expect(onFinished).toHaveBeenCalledTimes(1);
});
- it("sends selected logs, screenshot, and images together", async () => {
- const user = userEvent.setup();
- await renderModal("feedback");
+ it.each([
+ { input: "upload", type: "image/png", bytes: pngBytes },
+ { input: "paste", type: "image/png", bytes: pngBytes },
+ { input: "paste PNG without MIME type", type: "", bytes: pngBytes },
+ {
+ input: "paste JPEG without MIME type",
+ type: "",
+ bytes: new Uint8Array([0xff, 0xd8, 0xff]),
+ },
+ {
+ input: "paste WebP without MIME type",
+ type: "",
+ bytes: new Uint8Array([82, 73, 70, 70, 0, 0, 0, 0, 87, 69, 66, 80]),
+ },
+ ])(
+ "sends selected logs, screenshot, and images from $input together",
+ async ({ input, type, bytes }) => {
+ const user = userEvent.setup();
+ await renderModal("feedback");
- expect(readRecentLogs).not.toHaveBeenCalled();
- expect(captureScreenshot).toHaveBeenCalledTimes(1);
- expect(
- screen.getByRole("checkbox", {
- name: "Include screenshot of this window",
- }),
- ).not.toBeChecked();
- await user.click(
- screen.getByRole("checkbox", {
- name: "Include screenshot of this window",
- }),
- );
- let resolveLogs: (value: string | null) => void = () => {};
- readRecentLogs.mockImplementation(
- () =>
- new Promise((resolve) => {
- resolveLogs = resolve;
+ expect(readRecentLogs).not.toHaveBeenCalled();
+ expect(captureScreenshot).toHaveBeenCalledTimes(1);
+ expect(
+ screen.getByRole("checkbox", {
+ name: "Include screenshot of this window",
}),
- );
- const logsCheckbox = screen.getByRole("checkbox", {
- name: "Include recent app logs",
- });
- await user.click(logsCheckbox);
- expect(readRecentLogs).toHaveBeenCalledTimes(1);
- expect(logsCheckbox).toBeChecked();
- expect(logsCheckbox).toBeEnabled();
- expect(
- screen.queryByText("Loading recent app logs"),
- ).not.toBeInTheDocument();
- resolveLogs("[info] Example log");
- await screen.findByRole("button", { name: "View app logs" });
+ ).not.toBeChecked();
+ await user.click(
+ screen.getByRole("checkbox", {
+ name: "Include screenshot of this window",
+ }),
+ );
+ let resolveLogs: (value: string | null) => void = () => {};
+ readRecentLogs.mockImplementation(
+ () =>
+ new Promise((resolve) => {
+ resolveLogs = resolve;
+ }),
+ );
+ const logsCheckbox = screen.getByRole("checkbox", {
+ name: "Include recent app logs",
+ });
+ await user.click(logsCheckbox);
+ expect(readRecentLogs).toHaveBeenCalledTimes(1);
+ expect(logsCheckbox).toBeChecked();
+ expect(logsCheckbox).toBeEnabled();
+ expect(
+ screen.queryByText("Loading recent app logs"),
+ ).not.toBeInTheDocument();
+ resolveLogs("[info] Example log");
+ await screen.findByRole("button", { name: "View app logs" });
- const image = new File(["image bytes"], "feedback.png", {
- type: "image/png",
- });
- await user.upload(screen.getByLabelText("Choose feedback images"), image);
- expect(await screen.findByText("1 attached")).toBeInTheDocument();
+ const image = new File([bytes], "feedback.png", {
+ type,
+ });
+ if (input === "upload") {
+ await user.upload(
+ screen.getByLabelText("Choose feedback images"),
+ image,
+ );
+ } else {
+ fireEvent.paste(
+ screen.getByPlaceholderText(
+ "What happened, and what did you expect?",
+ ),
+ {
+ clipboardData: { files: [image], getData: () => "" },
+ },
+ );
+ }
+ expect(await screen.findByText("1 attached")).toBeInTheDocument();
+ expect(
+ await screen.findByRole("img", { name: "Attachment feedback.png" }),
+ ).toBeInTheDocument();
- await user.type(
- screen.getByPlaceholderText("What happened, and what did you expect?"),
- "The page did not load",
+ await user.type(
+ screen.getByPlaceholderText("What happened, and what did you expect?"),
+ "The page did not load",
+ );
+ await user.click(screen.getByRole("button", { name: "Send feedback" }));
+
+ await waitFor(() => expect(submitFeedback).toHaveBeenCalled());
+ expect(submitFeedback).toHaveBeenCalledWith(
+ expect.objectContaining({
+ feedbackAppLogs: "[info] Example log",
+ screenshot: {
+ name: "posthog-desktop-screenshot.jpg",
+ dataUrl: "data:image/jpeg;base64,c2NyZWVuc2hvdA==",
+ },
+ images: [
+ expect.objectContaining({
+ name: "feedback.png",
+ dataUrl: expect.stringMatching(/^data:image\/jpeg;base64,/),
+ }),
+ ],
+ }),
+ );
+ },
+ );
+
+ it("keeps text paste and lets users remove pasted images", async () => {
+ const user = userEvent.setup();
+ await renderModal("feedback");
+ const textarea = screen.getByPlaceholderText(
+ "What happened, and what did you expect?",
+ );
+ await user.click(textarea);
+ await user.paste("Example feedback");
+ expect(textarea).toHaveValue("Example feedback");
+ const accepted = fireEvent.paste(textarea, {
+ clipboardData: {
+ files: [new File([pngBytes], "pasted.png", { type: "image/png" })],
+ getData: () => "More context",
+ },
+ });
+ expect(accepted).toBe(true);
+ await user.click(
+ await screen.findByRole("button", { name: "Remove pasted.png" }),
);
await user.click(screen.getByRole("button", { name: "Send feedback" }));
-
- await waitFor(() => expect(submitFeedback).toHaveBeenCalled());
expect(submitFeedback).toHaveBeenCalledWith(
- expect.objectContaining({
- feedbackAppLogs: "[info] Example log",
- screenshot: {
- name: "posthog-desktop-screenshot.jpg",
- dataUrl: "data:image/jpeg;base64,c2NyZWVuc2hvdA==",
+ expect.objectContaining({ images: [] }),
+ );
+ });
+
+ it("shares the image limit between file selection and paste", async () => {
+ const user = userEvent.setup();
+ await renderModal("feedback");
+ await user.upload(
+ screen.getByLabelText("Choose feedback images"),
+ new File([pngBytes], "selected.png", { type: "image/png" }),
+ );
+ await screen.findByText("1 attached");
+ fireEvent.paste(
+ screen.getByPlaceholderText("What happened, and what did you expect?"),
+ {
+ clipboardData: {
+ files: ["second.png", "third.png"].map(
+ (name) => new File([pngBytes], name, { type: "image/png" }),
+ ),
+ getData: () => "",
},
- images: [
- expect.objectContaining({
- name: "feedback.png",
- dataUrl: expect.stringMatching(/^data:image\/jpeg;base64,/),
- }),
- ],
- }),
+ },
);
+ await screen.findByText("2 attached");
+ expect(
+ screen.queryByRole("img", { name: "Attachment third.png" }),
+ ).not.toBeInTheDocument();
});
+ it.each([
+ { type: "image/gif", bytes: pngBytes },
+ { type: "image/jpeg", bytes: pngBytes },
+ { type: "", bytes: new Uint8Array([1, 2, 3]) },
+ ])(
+ "blocks submission during image loading and rejects invalid images ($type)",
+ async ({ type, bytes }) => {
+ const user = userEvent.setup();
+ let finish: BlobCallback = () => {};
+ vi.spyOn(HTMLCanvasElement.prototype, "toBlob").mockImplementation(
+ (callback) => {
+ finish = callback;
+ },
+ );
+ await renderModal("feedback");
+ const textarea = screen.getByPlaceholderText(
+ "What happened, and what did you expect?",
+ );
+ await user.type(textarea, "Example feedback");
+ fireEvent.paste(textarea, {
+ clipboardData: {
+ files: [new File([pngBytes], "pasted.png", { type: "image/png" })],
+ getData: () => "",
+ },
+ });
+ await waitFor(() =>
+ expect(HTMLCanvasElement.prototype.toBlob).toHaveBeenCalled(),
+ );
+ expect(
+ screen.getByRole("button", { name: "Send feedback" }),
+ ).toBeDisabled();
+ await user.keyboard("{Meta>}{Enter}{/Meta}");
+ expect(submitFeedback).not.toHaveBeenCalled();
+ fireEvent.paste(textarea, {
+ clipboardData: {
+ files: [new File([pngBytes], "second.png", { type: "image/png" })],
+ getData: () => "",
+ },
+ });
+ expect(toastWarning).toHaveBeenCalledWith(
+ "An image is still loading. Wait, then paste it again.",
+ );
+ finish(new Blob(["image"], { type: "image/jpeg" }));
+ await screen.findByText("1 attached");
+ fireEvent.paste(textarea, {
+ clipboardData: {
+ files: [new File([bytes], "unsupported.gif", { type })],
+ getData: () => "",
+ },
+ });
+ await waitFor(() =>
+ expect(toastError).toHaveBeenCalledWith(
+ "Choose a JPEG, PNG, or WebP image.",
+ ),
+ );
+ expect(
+ screen.getByRole("button", { name: "Send feedback" }),
+ ).toBeEnabled();
+ },
+ );
+
it("does not add logs after they are unchecked while loading", async () => {
const user = userEvent.setup();
let resolveLogs: (value: string | null) => void = () => {};
diff --git a/products/desktop/packages/ui/src/features/feedback/FeedbackModal.tsx b/products/desktop/packages/ui/src/features/feedback/FeedbackModal.tsx
index 75e464972f57..c33df60675be 100644
--- a/products/desktop/packages/ui/src/features/feedback/FeedbackModal.tsx
+++ b/products/desktop/packages/ui/src/features/feedback/FeedbackModal.tsx
@@ -30,11 +30,16 @@ import {
captureException,
getAnalyticsSessionId,
} from "@posthog/ui/shell/analytics";
-import { useEffect, useState } from "react";
+import { useEffect, useRef, useState } from "react";
import {
FeedbackAttachments,
type FeedbackAttachmentsValue,
} from "./FeedbackAttachments";
+import {
+ type FeedbackImage,
+ MAX_FEEDBACK_IMAGE_COUNT,
+ readFeedbackImage,
+} from "./feedbackImages";
import type { FeedbackModalMode } from "./feedbackStore";
export type { FeedbackModalMode } from "./feedbackStore";
@@ -154,6 +159,7 @@ function FeedbackModalForm({
useState<NonNullable<FeedbackSubmissionInput["feedbackType"]>>("general");
const [view] = useState(getAppViewSnapshot);
const [submitting, setSubmitting] = useState(false);
+ const imagesLoadingRef = useRef(false);
const [attachments, setAttachments] = useState<FeedbackAttachmentsValue>({
includeScreenshot: false,
includeLogs: false,
@@ -170,7 +176,7 @@ function FeedbackModalForm({
const handleSubmit = async () => {
const response = value.trim();
- if (!canSubmit || !response) return;
+ if (!canSubmit || imagesLoadingRef.current || !response) return;
setSubmitting(true);
try {
const includeScreenshot =
@@ -210,6 +216,51 @@ function FeedbackModalForm({
}
};
+ const handleImageFiles = async (files: File[]): Promise<void> => {
+ if (submitting || files.length === 0) return;
+ if (imagesLoadingRef.current) {
+ toast.warning("An image is still loading. Wait, then paste it again.");
+ return;
+ }
+ const availableSlots = MAX_FEEDBACK_IMAGE_COUNT - attachments.images.length;
+ if (files.length > availableSlots) {
+ toast.warning(`You can attach up to ${MAX_FEEDBACK_IMAGE_COUNT} images.`);
+ }
+ if (availableSlots === 0) return;
+ imagesLoadingRef.current = true;
+ setAttachments((current) => ({ ...current, imagesLoading: true }));
+ try {
+ const nextImages = await Promise.all(
+ files.slice(0, availableSlots).map(async (file) => {
+ try {
+ return await readFeedbackImage(file);
+ } catch (error) {
+ toast.error(
+ error instanceof Error
+ ? error.message
+ : "Could not attach this image.",
+ );
+ return null;
+ }
+ }),
+ );
+ setAttachments((current) => ({
+ ...current,
+ images: [
+ ...current.images,
+ ...nextImages.filter(
+ (image): image is FeedbackImage =>
+ image !== null &&
+ !current.images.some((existing) => existing.id === image.id),
+ ),
+ ].slice(0, MAX_FEEDBACK_IMAGE_COUNT),
+ }));
+ } finally {
+ imagesLoadingRef.current = false;
+ setAttachments((current) => ({ ...current, imagesLoading: false }));
+ }
+ };
+
return (
<>
<DialogBody>
@@ -240,7 +291,18 @@ function FeedbackModalForm({
)}
<Textarea
value={value}
+ disabled={submitting}
onChange={(event) => setValue(event.target.value)}
+ onPaste={(event) => {
+ if (mode !== "feedback") return;
+ const files = Array.from(event.clipboardData.files).filter(
+ (file) => !file.type || file.type.startsWith("image/"),
+ );
+ if (files.length === 0) return;
+ if (!event.clipboardData.getData("text/plain"))
+ event.preventDefault();
+ void handleImageFiles(files);
+ }}
placeholder={MODAL_COPY[mode].placeholder}
rows={4}
maxLength={4000}
@@ -259,12 +321,15 @@ function FeedbackModalForm({
<Text size="xxs" variant="muted" className="mt-1">
Always included: app version and current page.
</Text>
- <FeedbackAttachments
- screenshot={initialScreenshot}
- value={attachments}
- onChange={setAttachments}
- contextClient={contextClient}
- />
+ <fieldset disabled={submitting} className="min-w-0">
+ <FeedbackAttachments
+ screenshot={initialScreenshot}
+ value={attachments}
+ onChange={setAttachments}
+ onImageFiles={handleImageFiles}
+ contextClient={contextClient}
+ />
+ </fieldset>
</>
)}
</div>
diff --git a/products/desktop/packages/ui/src/features/feedback/feedbackImages.ts b/products/desktop/packages/ui/src/features/feedback/feedbackImages.ts
index 87fca2dbd30e..9f4acfcc9168 100644
--- a/products/desktop/packages/ui/src/features/feedback/feedbackImages.ts
+++ b/products/desktop/packages/ui/src/features/feedback/feedbackImages.ts
@@ -16,6 +16,38 @@ export interface FeedbackImage {
dataUrl: string;
}
+async function detectImageType(file: File): Promise<string | null> {
+ const bytes = await new Promise<Uint8Array>((resolve, reject) => {
+ const reader = new FileReader();
+ reader.onload = () => {
+ if (reader.result instanceof ArrayBuffer) {
+ resolve(new Uint8Array(reader.result));
+ } else {
+ reject(new Error("Could not read this image."));
+ }
+ };
+ reader.onerror = () => reject(new Error("Could not read this image."));
+ reader.readAsArrayBuffer(file.slice(0, 12));
+ });
+ if ([0xff, 0xd8, 0xff].every((byte, index) => bytes[index] === byte)) {
+ return "image/jpeg";
+ }
+ if (
+ [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a].every(
+ (byte, index) => bytes[index] === byte,
+ )
+ ) {
+ return "image/png";
+ }
+ if (
+ String.fromCharCode(...bytes.slice(0, 4)) === "RIFF" &&
+ String.fromCharCode(...bytes.slice(8, 12)) === "WEBP"
+ ) {
+ return "image/webp";
+ }
+ return null;
+}
+
function blobToDataUrl(blob: Blob): Promise<string> {
return new Promise((resolve, reject) => {
const reader = new FileReader();
@@ -67,12 +99,16 @@ async function resizeImage(file: File): Promise<string> {
}
export async function readFeedbackImage(file: File): Promise<FeedbackImage> {
- if (!SUPPORTED_IMAGE_TYPES.has(file.type)) {
+ if (file.type && !SUPPORTED_IMAGE_TYPES.has(file.type)) {
throw new Error("Choose a JPEG, PNG, or WebP image.");
}
if (file.size > MAX_FEEDBACK_IMAGE_INPUT_BYTES) {
throw new Error("Choose an image smaller than 10 MB.");
}
+ const detectedType = await detectImageType(file);
+ if (!detectedType || (file.type && file.type !== detectedType)) {
+ throw new Error("Choose a JPEG, PNG, or WebP image.");
+ }
return {
id: `${file.name}:${file.size}:${file.lastModified}`,