Skip to content

Commit c574614

Browse files
committed
fix(file upload): show clear error message if file is too large for upload
fixes #2462
1 parent b213fa0 commit c574614

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/app/features/file/edit-file/edit-file.component.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export class EditFileComponent extends EditComponent<string> implements OnInit {
8686
}
8787

8888
protected saveNewFile(file: File) {
89-
// The maximum file size which can be processed by CouchDB before a timeout is around 200mb
89+
// The maximum file size is set to 5 MB
9090
this.fileService
9191
.uploadFile(file, this.entity, this.formControlName)
9292
.subscribe({
@@ -100,7 +100,13 @@ export class EditFileComponent extends EditComponent<string> implements OnInit {
100100

101101
private handleError(err) {
102102
Logging.error("Failed uploading file: " + JSON.stringify(err));
103-
this.alertService.addDanger("Could not upload file, please try again.");
103+
104+
let errorMessage = $localize`:File Upload Error Message:Failed uploading file. Please try again.`;
105+
if (err?.status === 413) {
106+
errorMessage = $localize`:File Upload Error Message:File too large. Usually files up to 5 MB are supported.`;
107+
}
108+
this.alertService.addDanger(errorMessage);
109+
104110
// Reset entity to how it was before
105111
this.entity[this.formControlName] = this.initialValue;
106112
this.formControl.setValue(this.initialValue);

0 commit comments

Comments
 (0)