export type CreateApiDamFoldersFolderIdFilesArgs = {folder_id: string, body: BodyInit}; export type CreateApiDamFoldersFolderIdFilesOptions = {baseUrl: string, OAuth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a new file * * POST /dam/folders/{folder_id}/files */ export const createApiDamFoldersFolderIdFiles = async (args: CreateApiDamFoldersFolderIdFilesArgs, options: CreateApiDamFoldersFolderIdFilesOptions) => { const {baseUrl, fetch: fetchFn = fetch, OAuth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "multipart/form-data") if (OAuth2 !== undefined) headers.set('authorization', `Bearer ${OAuth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/dam/folders/${encodeURIComponent(String(args.folder_id))}/files${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };