Rename all workspace packages from @paperclip/* to @paperclipai/* and the CLI binary from `paperclip` to `paperclipai` in preparation for npm publishing. Bump CLI version to 0.1.0 and add package metadata (description, keywords, license, repository, files). Update all imports, documentation, user-facing messages, and tests accordingly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
22 lines
883 B
TypeScript
22 lines
883 B
TypeScript
import type { AssetImage } from "@paperclipai/shared";
|
|
import { api } from "./client";
|
|
|
|
export const assetsApi = {
|
|
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", safeFile);
|
|
if (namespace && namespace.trim().length > 0) {
|
|
form.append("namespace", namespace.trim());
|
|
}
|
|
return api.postForm<AssetImage>(`/companies/${companyId}/assets/images`, form);
|
|
},
|
|
};
|
|
|