({
apiURI,
appId,
path,
file,
refreshToken,
contentType,
contentDisposition,
}: {
apiURI: string;
appId: string;
path: string;
file: File | Blob;
refreshToken?: string;
contentType?: string;
contentDisposition?: string;
})
| 13 | }; |
| 14 | |
| 15 | export 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 | |
| 51 | export async function deleteFile({ |
| 52 | apiURI, |
nothing calls this directly
no test coverage detected