Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit 4030608

Browse files
feat: limit profile image to 0.5 Mb
1 parent a8dc085 commit 4030608

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

studio/src/app/modals/editor/app-custom-images/app-custom-images.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export class AppCustomImages {
173173
if (filePicker.files && filePicker.files.length > 0) {
174174
this.uploading = true;
175175

176-
const storageFile: StorageFile = await this.storageService.uploadImage(filePicker.files[0], 'images');
176+
const storageFile: StorageFile = await this.storageService.uploadImage(filePicker.files[0], 'images', 10485760);
177177

178178
if (storageFile) {
179179
await this.selectAndClose(storageFile);

studio/src/app/pages/core/app-settings/app-settings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ export class AppHome {
229229
}
230230

231231
try {
232-
const storageFile: StorageFile = await this.storageService.uploadImage(this.profilePicture, 'avatars');
232+
const storageFile: StorageFile = await this.storageService.uploadImage(this.profilePicture, 'avatars', 524288);
233233

234234
if (storageFile) {
235235
this.user.data.photo_url = storageFile.downloadUrl;

studio/src/app/services/storage/storage.service.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class StorageService {
3131
return StorageService.instance;
3232
}
3333

34-
uploadImage(image: File, folder: string): Promise<StorageFile> {
34+
uploadImage(image: File, folder: string, maxSize: number): Promise<StorageFile> {
3535
return new Promise<StorageFile>((resolve) => {
3636
try {
3737
this.apiUserService.watch().pipe(take(1)).subscribe(async (apiUser: ApiUser) => {
@@ -48,7 +48,7 @@ export class StorageService {
4848
}
4949

5050
if (image.size > 10485760) {
51-
this.errorService.error('Image is too big (max. 10 Mb)');
51+
this.errorService.error(`Image is too big (max. ${maxSize / 1048576} Mb)`);
5252
resolve();
5353
return;
5454
}

0 commit comments

Comments
 (0)