export type UpdateApiBedrockFilesBucketKeyArgs = {bucket: string, key: string, 'x-model-provider'?: string | undefined, body: BodyInit}; export type UpdateApiBedrockFilesBucketKeyOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * S3-compatible PutObject * * PUT /bedrock/files/{bucket}/{key} * * Also accepts auth: BasicAuth, VirtualKeyAuth, ApiKeyAuth */ export const updateApiBedrockFilesBucketKey = async (args: UpdateApiBedrockFilesBucketKeyArgs, options?: UpdateApiBedrockFilesBucketKeyOptions) => { const {baseUrl = "http://localhost:8080", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/octet-stream") if (args['x-model-provider'] != null) headers.set("x-model-provider", String(args['x-model-provider'])) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/bedrock/files/${encodeURIComponent(String(args.bucket))}/${encodeURIComponent(String(args.key))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 undefined };