From c5840192dae803d49d0bded7bd2c8d461731a9c3 Mon Sep 17 00:00:00 2001 From: Daniel Rochetti Date: Mon, 20 Nov 2023 09:13:18 -0800 Subject: [PATCH] feat(client): allow to disable auto-upload --- libs/client/package.json | 2 +- libs/client/src/function.ts | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/libs/client/package.json b/libs/client/package.json index 73538ae..70b90ae 100644 --- a/libs/client/package.json +++ b/libs/client/package.json @@ -1,7 +1,7 @@ { "name": "@fal-ai/serverless-client", "description": "The fal serverless JS/TS client", - "version": "0.5.3", + "version": "0.5.4", "license": "MIT", "repository": { "type": "git", diff --git a/libs/client/src/function.ts b/libs/client/src/function.ts index 4574e2e..c10a810 100644 --- a/libs/client/src/function.ts +++ b/libs/client/src/function.ts @@ -24,6 +24,16 @@ type RunOptions = { * The HTTP method, defaults to `post`; */ readonly method?: 'get' | 'post' | 'put' | 'delete' | string; + + /** + * If `true`, the function will automatically upload any files + * (i.e. instances of `Blob`) or data:uri in the input. + * + * You can disable this behavior by setting it to `false`, which + * is useful in cases where you want to upload the files yourself + * or use small data:uri in the input. + */ + readonly autoUpload?: boolean; }; /** @@ -71,9 +81,10 @@ export async function run( id: string, options: RunOptions = {} ): Promise { - const input = options.input - ? await storageImpl.transformInput(options.input) - : options.input; + const input = + options.input && options.autoUpload !== false + ? await storageImpl.transformInput(options.input) + : options.input; return dispatchRequest( options.method ?? 'post', buildUrl(id, options),