Skip to content

Commit

Permalink
fix(clerk-js): Add base64 string support for organization logo
Browse files Browse the repository at this point in the history
fix(clerk-js): Add base64 string support for organization logo

fix(clerk-js): Add base64 string support for organization logo
  • Loading branch information
raptisj committed Jun 12, 2023
1 parent b9d23a4 commit c42b4ac
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/nervous-pumas-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@clerk/clerk-js': minor
'@clerk/types': minor
---

Add base64 string support in Organization.setLogo
14 changes: 12 additions & 2 deletions packages/clerk-js/src/core/resources/Organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,23 @@ export class Organization extends BaseResource implements OrganizationResource {
}).then(res => new Organization(res?.response as OrganizationJSON));
}

const body = new FormData();
body.append('file', file);
let body;
let headers;
if (typeof file === 'string') {
body = file;
headers = new Headers({
'Content-Type': 'application/octet-stream',
});
} else {
body = new FormData();
body.append('file', file);
}

return await BaseResource._fetch({
path: `/organizations/${this.id}/logo`,
method: 'PUT',
body,
headers,
}).then(res => new Organization(res?.response as OrganizationJSON));
};

Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ export interface UpdateOrganizationParams {
}

export interface SetOrganizationLogoParams {
file: Blob | File | null;
file: Blob | File | string | null;
}

0 comments on commit c42b4ac

Please sign in to comment.