Skip to content

Commit 3357665

Browse files
authored
Merge pull request #382 from ReadAlongs/dev.ej/fix-size-limits
Restore smaller upload file size limits
2 parents 1a73c5d + 4bba75e commit 3357665

File tree

5 files changed

+40
-13
lines changed

5 files changed

+40
-13
lines changed

package-lock.json

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/studio-web/src/app/upload/upload.component.ts

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ export class UploadComponent implements OnDestroy, OnInit {
5959
contactLink = environment.packageJson.contact;
6060
progressMode: ProgressBarMode = "indeterminate";
6161
progressValue = 0;
62-
maxTxtSizeKB = 250; // Max 250 KB plain text file size
63-
maxRasSizeKB = 250; // Max 250 KB .readalong XML text size
62+
// Max plain text file size: 40KB is OK but takes around 15-20s on Heroku
63+
maxTxtSizeKB = 40;
64+
// Max .readalong XML text size: text * 5 is a rough heuristic; the XML is much bloated from the text.
65+
maxRasSizeKB = 200;
6466
@ViewChild("textInputElement") textInputElement: ElementRef;
6567
@Output() stepChange = new EventEmitter<any[]>();
6668

@@ -332,10 +334,25 @@ Please check it to make sure all words are spelled out completely, e.g. write "4
332334
}
333335
if (this.studioService.inputMethod.text === "edit") {
334336
if (this.studioService.$textInput.value) {
335-
let inputText = new Blob([this.studioService.$textInput.value], {
336-
type: "text/plain",
337-
});
338-
this.studioService.textControl$.setValue(inputText);
337+
const inputLength = this.studioService.$textInput.value.length;
338+
if (inputLength > this.maxTxtSizeKB * 1024) {
339+
this.toastr.error(
340+
$localize`Text too large. Max size: ` +
341+
this.maxTxtSizeKB +
342+
$localize` KB.` +
343+
$localize` Current size: ` +
344+
Math.ceil(inputLength / 1024) +
345+
$localize` KB.`,
346+
$localize`Sorry!`,
347+
{ timeOut: 15000 },
348+
);
349+
return;
350+
} else {
351+
let inputText = new Blob([this.studioService.$textInput.value], {
352+
type: "text/plain",
353+
});
354+
this.studioService.textControl$.setValue(inputText);
355+
}
339356
} else {
340357
this.toastr.error(
341358
$localize`Please enter text to align.`,
@@ -525,8 +542,9 @@ Please check it to make sure all words are spelled out completely, e.g. write "4
525542
: this.maxTxtSizeKB;
526543
if (file.size > maxSizeKB * 1024) {
527544
this.toastr.error(
528-
$localize`File too large. Max size: ` + maxSizeKB + $localize` KB`,
545+
$localize`File too large. Max size: ` + maxSizeKB + $localize` KB.`,
529546
$localize`Sorry!`,
547+
{ timeOut: 15000 },
530548
);
531549
this.textInputElement.nativeElement.value = "";
532550
} else {

packages/studio-web/src/i18n/messages.es.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@
154154
"1983793909601149790": "Por favor inténtelo de nuevo o seleccione un fichero pre-grabado.",
155155
"3896053555277429649": "Por favor seleccione un idioma o la opción predeterminada",
156156
"8052409322099101104": "Ningún idioma seleccionado",
157+
"2970892766726423212": "El texto es demasiado grande. Tamaño máximo: ",
158+
"1227277325872790936": " KB.",
159+
"4346774921429520933": " Tamaño actual: ",
157160
"3533349926767927338": "Por favor entre el texto que quiere alinear.",
158161
"7881212750036563398": "Sin texto",
159162
"3578398528078428417": "Por favor seleccione un fichero de texto.",
@@ -170,7 +173,6 @@
170173
"1326685349515945581": " procesado pero no cargado. Su audio se mantendrá en su computadora.",
171174
"6899344040225872362": "¡Genial!",
172175
"7895338145504956239": "Fichero demasiado grande. Tamaño máximo: ",
173-
"5997429059663319535": " KB",
174176
"2722548994886578004": " procesado. El texto se cargará mediante una conexión encriptada cuando pase al próximo paso."
175177
}
176178
}

packages/studio-web/src/i18n/messages.fr.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@
154154
"1983793909601149790": "Prière de réessayer ou de choisir un fichier pré-enregistré.",
155155
"3896053555277429649": "Prière de choisir une langue ou l'option par défaut",
156156
"8052409322099101104": "Pas de langue choisie",
157+
"2970892766726423212": "Texte trop long. Limite: ",
158+
"1227277325872790936": " Ko.",
159+
"4346774921429520933": " Taille actuelle: ",
157160
"3533349926767927338": "Prière de saisir le texte à aligner.",
158161
"7881212750036563398": "Pas de texte",
159162
"3578398528078428417": "Prière de choisir un fichier texte.",
@@ -170,7 +173,6 @@
170173
"1326685349515945581": " lu, mais pas téléversé. Votre audio restera sur votre ordinateur.",
171174
"6899344040225872362": "Bravo!",
172175
"7895338145504956239": "Fichier trop lourd. Poids maximal: ",
173-
"5997429059663319535": " Ko",
174176
"2722548994886578004": " lu. Il sera téléversé à l'aide d'une connexion chiffrée quand vous passerez à la prochaine étape."
175177
}
176178
}

packages/studio-web/src/i18n/messages.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@
154154
"1983793909601149790": "Please try again, or select a pre-recorded file.",
155155
"3896053555277429649": "Please select a language or choose the default option",
156156
"8052409322099101104": "No language selected",
157+
"2970892766726423212": "Text too large. Max size: ",
158+
"1227277325872790936": " KB.",
159+
"4346774921429520933": " Current size: ",
157160
"3533349926767927338": "Please enter text to align.",
158161
"7881212750036563398": "No text",
159162
"3578398528078428417": "Please select a text file.",
@@ -170,7 +173,6 @@
170173
"1326685349515945581": " processed, but not uploaded. Your audio will stay on your computer.",
171174
"6899344040225872362": "Great!",
172175
"7895338145504956239": "File too large. Max size: ",
173-
"5997429059663319535": " KB",
174176
"2722548994886578004": " processed. It will be uploaded through an encrypted connection when you go to the next step."
175177
}
176178
}

0 commit comments

Comments
 (0)