export type FileExistenceCheckSchema = {directory_path: string, file_name: string, file_type?: ('FILE' | 'DIRECTORY' | 'SYMLINK' | 'SEQUENCE') | undefined, template?: string | undefined, template_engine?: string | undefined}; export type CreateApiV1FilesStoragesStorageIdArgs = {'App-ID': string, 'Auth-Token': string, storage_id: string, get_file_size?: boolean | undefined, body: FileExistenceCheckSchema}; export type CreateApiV1FilesStoragesStorageIdOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Check file is on storage * * POST /v1/files/storages/{storage_id}/ */ export const createApiV1FilesStoragesStorageId = async (args: CreateApiV1FilesStoragesStorageIdArgs, options: CreateApiV1FilesStoragesStorageIdOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['App-ID'] != null) headers.set("App-ID", String(args['App-ID'])) if (args['Auth-Token'] != null) headers.set("Auth-Token", String(args['Auth-Token'])) if (args.get_file_size != null) query.append("get_file_size", String(args.get_file_size)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/files/storages/${encodeURIComponent(String(args.storage_id))}/${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };