mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-15 02:20:38 +09:00
fix: resolve image upload ERR_ACCESS_DENIED and dialog a11y warning
Eagerly read file data into memory via arrayBuffer() before constructing
FormData for the upload fetch. Clipboard-paste File objects from the MDX
editor reference transient browser data that may be discarded after the
paste event handler returns; streaming that stale reference in the fetch
body causes net::ERR_ACCESS_DENIED. Reading into an ArrayBuffer first
makes the FormData self-contained.
Also suppress the Radix UI "Missing Description" console warning on the
NewIssueDialog by setting aria-describedby={undefined}.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f800374f3a
commit
4b7fdaea01
2 changed files with 10 additions and 2 deletions
|
|
@ -2,9 +2,16 @@ import type { AssetImage } from "@paperclip/shared";
|
|||
import { api } from "./client";
|
||||
|
||||
export const assetsApi = {
|
||||
uploadImage: (companyId: string, file: File, namespace?: string) => {
|
||||
uploadImage: async (companyId: string, file: File, namespace?: string) => {
|
||||
// Read file data into memory eagerly so the fetch body is self-contained.
|
||||
// Clipboard-paste File objects reference transient data that the browser may
|
||||
// discard after the paste-event handler returns, causing ERR_ACCESS_DENIED
|
||||
// when fetch() later tries to stream the FormData body.
|
||||
const buffer = await file.arrayBuffer();
|
||||
const safeFile = new File([buffer], file.name, { type: file.type });
|
||||
|
||||
const form = new FormData();
|
||||
form.append("file", file);
|
||||
form.append("file", safeFile);
|
||||
if (namespace && namespace.trim().length > 0) {
|
||||
form.append("namespace", namespace.trim());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue