Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce fal cdn v3 with storage API #106

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion libs/client/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
* @returns the file extension or `bin` if the content type is not recognized.
*/
function getExtensionFromContentType(contentType: string): string {
const [_, fileType] = contentType.split("/");

Check warning on line 49 in libs/client/src/storage.ts

View workflow job for this annotation

GitHub Actions / build

'_' is assigned a value but never used
return fileType.split(/[-;]/)[0] ?? "bin";
}

Expand All @@ -66,7 +66,8 @@
file.name || `${Date.now()}.${getExtensionFromContentType(contentType)}`;
return await dispatchRequest<InitiateUploadData, InitiateUploadResult>({
method: "POST",
targetUrl: `${getRestApiUrl()}/storage/upload/initiate`,
// NOTE: We want to test V3 without making it the default at the API level
targetUrl: `${getRestApiUrl()}/storage/upload/initiate?storage_type=fal-cdn-v3`,
input: {
content_type: contentType,
file_name: filename,
Expand Down Expand Up @@ -110,7 +111,7 @@
} else if (input instanceof Blob) {
return await ref.upload(input);
} else if (isPlainObject(input)) {
const inputObject = input as Record<string, any>;

Check warning on line 114 in libs/client/src/storage.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
const promises = Object.entries(inputObject).map(
async ([key, value]): Promise<KeyValuePair> => {
return [key, await ref.transformInput(value)];
Expand Down
Loading