fix: nested blob upload (#48)
* fix: nested blob upload * refactor: export to a utility function * chore: bump version to 0.8.3
This commit is contained in:
parent
9cc7cf5456
commit
66d817b2a6
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@fal-ai/serverless-client",
|
"name": "@fal-ai/serverless-client",
|
||||||
"description": "The fal serverless JS/TS client",
|
"description": "The fal serverless JS/TS client",
|
||||||
"version": "0.8.2",
|
"version": "0.8.3",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { getConfig, getRestApiUrl } from './config';
|
import { getConfig, getRestApiUrl } from './config';
|
||||||
import { dispatchRequest } from './request';
|
import { dispatchRequest } from './request';
|
||||||
|
import { isPlainObject } from './utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File support for the client. This interface establishes the contract for
|
* File support for the client. This interface establishes the contract for
|
||||||
@ -117,6 +118,9 @@ export const storageImpl: StorageSupport = {
|
|||||||
const url = await storageImpl.upload(blob as Blob);
|
const url = await storageImpl.upload(blob as Blob);
|
||||||
return [key, url];
|
return [key, url];
|
||||||
}
|
}
|
||||||
|
if (isPlainObject(value)) {
|
||||||
|
return [key, await storageImpl.transformInput(value)];
|
||||||
|
}
|
||||||
return [key, value] as KeyValuePair;
|
return [key, value] as KeyValuePair;
|
||||||
});
|
});
|
||||||
const results = await Promise.all(promises);
|
const results = await Promise.all(promises);
|
||||||
|
|||||||
@ -82,3 +82,12 @@ export function isReact() {
|
|||||||
}
|
}
|
||||||
return isRunningInReact;
|
return isRunningInReact;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a value is a plain object.
|
||||||
|
* @param value - The value to check.
|
||||||
|
* @returns `true` if the value is a plain object, `false` otherwise.
|
||||||
|
*/
|
||||||
|
export function isPlainObject(value: any): boolean {
|
||||||
|
return !!value && Object.getPrototypeOf(value) === Object.prototype;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user