@oystehr/sdk
Version:
Oystehr SDK
25 lines (22 loc) • 580 B
text/typescript
import { SDKResource } from '../../client/client';
function baseUrlThunk(this: SDKResource): string {
return this.config.services?.['projectApiUrl'] ?? 'https://project-api.zapehr.com/v1';
}
export async function uploadFile(
this: SDKResource,
{
id,
file,
filename,
}: {
id: string;
file: Blob;
filename?: string | undefined;
}
): Promise<void> {
const uploadUrl = await this.request('/zambda/{id}/s3-upload', 'post', baseUrlThunk.bind(this))({ id, filename });
await fetch(uploadUrl.signedUrl, {
method: 'PUT',
body: file,
});
}