MCPcopy Create free account
hub / github.com/instantdb/instant / uploadFile

Function uploadFile

client/packages/core/src/StorageAPI.ts:15–49  ·  view source on GitHub ↗
({
  apiURI,
  appId,
  path,
  file,
  refreshToken,
  contentType,
  contentDisposition,
}: {
  apiURI: string;
  appId: string;
  path: string;
  file: File | Blob;
  refreshToken?: string;
  contentType?: string;
  contentDisposition?: string;
})

Source from the content-addressed store, hash-verified

13};
14
15export async function uploadFile({
16 apiURI,
17 appId,
18 path,
19 file,
20 refreshToken,
21 contentType,
22 contentDisposition,
23}: {
24 apiURI: string;
25 appId: string;
26 path: string;
27 file: File | Blob;
28 refreshToken?: string;
29 contentType?: string;
30 contentDisposition?: string;
31}): Promise<UploadFileResponse> {
32 const headers = {
33 app_id: appId,
34 path,
35 authorization: `Bearer ${refreshToken}`,
36 'content-type': contentType || file.type,
37 };
38 if (contentDisposition) {
39 headers['content-disposition'] = contentDisposition;
40 }
41
42 const data = await jsonFetch(`${apiURI}/storage/upload`, {
43 method: 'PUT',
44 headers,
45 body: file,
46 });
47
48 return data;
49}
50
51export async function deleteFile({
52 apiURI,

Callers

nothing calls this directly

Calls 1

jsonFetchFunction · 0.50

Tested by

no test coverage detected