Skip to content

Commit

Permalink
refactor(console,phrases,schemas): increase file upload size limit to…
Browse files Browse the repository at this point in the history
… 10 mb
  • Loading branch information
charIeszhao committed Jul 18, 2024
1 parent 17d7be3 commit 361a65d
Show file tree
Hide file tree
Showing 17 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useTranslation } from 'react-i18next';

import UploaderIcon from '@/assets/icons/upload.svg';
import useApi from '@/hooks/use-api';
import { convertToFileExtensionArray } from '@/utils/uploader';
import { convertToFileExtensionArray, formatBytes } from '@/utils/uploader';

import { Ring } from '../../Spinner';

Expand Down Expand Up @@ -94,7 +94,9 @@ function FileUploader<T extends Record<string, unknown> = UserAssets>({
const fileSizeLimit = Math.min(maxSize, maxUploadFileSize);

if (acceptedFile.size > fileSizeLimit) {
setUploadError(t('components.uploader.error_file_size', { size: fileSizeLimit / 1024 }));
setUploadError(
t('components.uploader.error_file_size', { limitWithUnit: formatBytes(fileSizeLimit) })
);

return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const components = {
image_limit:
'Lade ein Bild unter {{size, number}}KB hoch, nur {{extensions, list(style: narrow; type: conjunction;)}}.',
error_upload: 'Etwas ist schiefgelaufen. Dateiupload fehlgeschlagen.',
error_file_size: 'Dateigröße ist zu groß. Bitte lade eine Datei unter {{size, number}}KB hoch.',
error_file_size: 'Dateigröße ist zu groß. Bitte lade eine Datei unter {{limitWithUnit}} hoch.',
error_file_type:
'Dateityp wird nicht unterstützt. Nur {{extensions, list(style: narrow; type: conjunction;)}}.',
error_file_count: 'Sie können nur 1 Datei hochladen.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const components = {
image_limit:
'Upload image under {{size, number}}KB, {{extensions, list(style: narrow; type: conjunction;)}} only.',
error_upload: 'Something went wrong. File upload failed.',
error_file_size: 'File size is too large. Please upload a file under {{size, number}}KB.',
error_file_size: 'File size is too large. Please upload a file under {{limitWithUnit}}.',
error_file_type:
'File type is not supported. {{extensions, list(style: narrow; type: conjunction;)}} only.',
error_file_count: 'You can only upload 1 file.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const components = {
'Sube imágenes de menos de {{size, number}}KB, solo {{extensions, list(style: narrow; type: conjunction;)}}.',
error_upload: 'Algo salió mal. La subida de archivos falló.',
error_file_size:
'El archivo es demasiado grande. Por favor, sube un archivo de menos de {{size, number}}KB.',
'El archivo es demasiado grande. Por favor, sube un archivo de menos de {{limitWithUnit}}.',
error_file_type:
'El tipo de archivo no es compatible. Solo {{extensions, list(style: narrow; type: conjunction;)}}.',
error_file_count: 'Solo puedes subir 1 archivo.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const components = {
'Téléchargez une image de moins de {{size, number}} Ko, uniquement {{extensions, list(style: narrow; type: conjunction;)}}.',
error_upload: "Quelque chose s'est mal passé. La téléchargement de fichier a échoué.",
error_file_size:
'La taille du fichier est trop grande. Veuillez télécharger un fichier de moins de {{size, number}}Ko.',
'La taille du fichier est trop grande. Veuillez télécharger un fichier de moins de {{limitWithUnit}}Ko.',
error_file_type:
"Le type de fichier n'est pas pris en charge. Uniquement {{extensions, list(style: narrow; type: conjunction;)}}.",
error_file_count: 'Vous ne pouvez télécharger qu’un seul fichier.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const components = {
image_limit:
'Carica immagini sotto i {{size, number}}KB, solo {{extensions, list(style: narrow; type: conjunction;)}}.',
error_upload: 'Qualcosa è andato storto. Caricamento fallito.',
error_file_size: 'Il file è troppo grande. Carica un file sotto i {{size, number}}KB.',
error_file_size: 'Il file è troppo grande. Carica un file sotto i {{limitWithUnit}}.',
error_file_type:
'Formato file non supportato. Sono accettati solo formati {{extensions, list(style: narrow; type: conjunction;)}}.',
error_file_count: 'Puoi caricare solo 1 file.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const components = {
image_limit:
'{{size, number}}KB以下のイメージをアップロードし、{{extensions, list(style: narrow; type: conjunction;)}}のみ許可します。',
error_upload: 'エラーが発生しました。ファイルのアップロードに失敗しました。',
error_file_size: '{{size, number}}KB以下のファイルをアップロードしてください。',
error_file_size: '{{limitWithUnit}} 以下のファイルをアップロードしてください。',
error_file_type:
'{{extensions, list(style: narrow; type: conjunction;)}}のみサポートされます。',
error_file_count: '1つのファイルしかアップロードできません。',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const components = {
image_limit:
'{{size, number}}KB 미만의 {{extensions, list(style: narrow; type: conjunction;)}} 파일만 업로드하세요.',
error_upload: '오류가 발생했습니다. 파일 업로드에 실패하였습니다.',
error_file_size: '파일 크기가 너무 커요. {{size, number}}KB 미만의 파일을 업로드해 주세요.',
error_file_size: '파일 크기가 너무 커요. {{limitWithUnit}} 미만의 파일을 업로드해 주세요.',
error_file_type:
'지원되지 않는 파일 유형이에요. {{extensions, list(style: narrow; type: conjunction;)}} 파일만 사용 가능해요.',
error_file_count: '파일은 1개만 업로드 가능합니다.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const components = {
'Wyślij obraz o rozmiarze mniejszym niż {{size, number}}KB, tylko w formacie {{extensions, list(style: narrow; type: conjunction;)}}.',
error_upload: 'Coś poszło nie tak. Nie udało się wysłać pliku.',
error_file_size:
'Plik jest zbyt duży. Wyślij plik o rozmiarze mniejszym niż {{size, number}}KB.',
'Plik jest zbyt duży. Wyślij plik o rozmiarze mniejszym niż {{limitWithUnit}}.',
error_file_type:
'Ten typ pliku nie jest obsługiwany. Obsługiwane formaty to {{extensions, list(style: narrow; type: conjunction;)}}.',
error_file_count: 'Możesz przesłać tylko 1 plik.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const components = {
'Carregue imagens abaixo de {{size, number}}KB, apenas {{extensions, list(style: narrow; type: conjunction;)}}.',
error_upload: 'Algo deu errado. Falha ao enviar arquivo.',
error_file_size:
'Tamanho do arquivo é muito grande. Por favor, envie um arquivo abaixo de {{size, number}}KB.',
'Tamanho do arquivo é muito grande. Por favor, envie um arquivo abaixo de {{limitWithUnit}}.',
error_file_type:
'Tipo de arquivo não é suportado. Apenas {{extensions, list(style: narrow; type: conjunction;)}}.',
error_file_count: 'Você só pode enviar 1 arquivo.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const components = {
'Carregue imagens com menos de {{size, number}}KB, só {{extensions, list(style: narrow; type: conjunction;)}}.',
error_upload: 'Algo correu mal. O carregamento do ficheiro falhou.',
error_file_size:
'O ficheiro é demasiado grande. Por favor carregue um ficheiro com menos de {{size, number}}KB.',
'O ficheiro é demasiado grande. Por favor carregue um ficheiro com menos de {{limitWithUnit}}.',
error_file_type:
'O tipo de ficheiro não é suportado. Apenas {{extensions, list(style: narrow; type: conjunction;)}}.',
error_file_count: 'Só é possível carregar 1 ficheiro.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const components = {
'Загрузите изображение размером менее {{size, number}} КБ, только {{extensions, list(style: narrow; type: conjunction;)}}.',
error_upload: 'Что-то пошло не так. Загрузка файла не удалась.',
error_file_size:
'Размер файла слишком большой. Пожалуйста, загрузите файл размером менее {{size, number}} КБ.',
'Размер файла слишком большой. Пожалуйста, загрузите файл размером менее {{limitWithUnit}}.',
error_file_type:
'Тип файла не поддерживается. Допустимы только файлы типа {{extensions, list(style: narrow; type: conjunction;)}}.',
error_file_count: 'Вы можете загрузить только 1 файл.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ const components = {
image_limit:
'{{size, number}}KB altındaki resimleri yükleyin, yalnızca {{extensions, list(style: narrow; type: conjunction;)}} dosyaları kabul edilir.',
error_upload: 'Bir şeyler yanlış gitti. Dosya yüklenemedi.',
error_file_size:
'Dosya boyutu çok büyük. Lütfen {{size, number}}KB altında bir dosya yükleyin.',
error_file_size: 'Dosya boyutu çok büyük. Lütfen {{limitWithUnit}} altında bir dosya yükleyin.',
error_file_type:
'Dosya türü desteklenmiyor. Yalnızca {{extensions, list(style: narrow; type: conjunction;)}} dosyaları kabul edilir.',
error_file_count: 'Sadece 1 dosya yükleyebilirsiniz.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const components = {
image_limit:
'上传图片大小不能超过 {{size, number}}KB,只支持 {{extensions, list(style: narrow; type: conjunction;)}} 格式的文件。',
error_upload: '哎呀,出了些问题。文件上传失败。',
error_file_size: '文件太大了,请上传小于 {{size, number}}KB 的文件。',
error_file_size: '文件太大了,请上传小于 {{limitWithUnit}} 的文件。',
error_file_type:
'不支持该文件类型。只支持 {{extensions, list(style: narrow; type: conjunction;)}} 格式的文件。',
error_file_count: '只能上传一个文件。',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const components = {
image_limit:
'上傳圖片大小不能超過 {{size, number}}KB,只支援 {{extensions, list(style: narrow; type: conjunction;)}} 格式的檔案。',
error_upload: '哎呀,出了些問題。檔案上傳失敗。',
error_file_size: '檔案太大了,請上傳小於 {{size, number}}KB 的檔案。',
error_file_size: '檔案太大了,請上傳小於 {{limitWithUnit}} 的檔案。',
error_file_type:
'不支援該檔案格式,只支援 {{extensions, list(style: narrow; type: conjunction;)}} 格式的檔案。',
error_file_count: '你只能上載一個檔案。',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const components = {
image_limit:
'上傳圖片大小不能超過 {{size, number}}KB,只支持 {{extensions, list(style: narrow; type: conjunction;)}} 格式的文件。',
error_upload: '哎呀,出了些問題。文件上傳失敗。',
error_file_size: '文件太大了,請上傳小於 {{size, number}}KB 的文件。',
error_file_size: '文件太大了,請上傳小於 {{limitWithUnit}} 的文件。',
error_file_type:
'不支持該文件類型。只支持 {{extensions, list(style: narrow; type: conjunction;)}} 格式的文件。',
error_file_count: '您只能上傳一個檔案。',
Expand Down
2 changes: 1 addition & 1 deletion packages/schemas/src/types/user-assets.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { z } from 'zod';

export const maxUploadFileSize = 8 * 1024 * 1024; // 8MB
export const maxUploadFileSize = 10 * 1024 * 1024; // 10 MB

// Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
export const allowUploadMimeTypes = [
Expand Down

0 comments on commit 361a65d

Please sign in to comment.