diff --git a/locales/en-US.yml b/locales/en-US.yml index bee6111fc..fa0d9d28e 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -233,6 +233,9 @@ resetAreYouSure: "Really reset?" saved: "Saved" messaging: "Chat" upload: "Upload" +uploadFailed: "Upload failed" +uploadFailedDescription: "The file could not be uploaded." +uploadFailedSize: "The file is too large to be uploaded." keepOriginalUploading: "Keep original image" keepOriginalUploadingDescription: "Saves the originally uploaded image as-is. If turned\ \ off, a version to display on the web will be generated on upload." diff --git a/packages/client/src/scripts/upload.ts b/packages/client/src/scripts/upload.ts index 249663793..fd376b6ae 100644 --- a/packages/client/src/scripts/upload.ts +++ b/packages/client/src/scripts/upload.ts @@ -83,10 +83,18 @@ export function uploadFile( // TODO: 消すのではなくて再送できるようにしたい uploads.value = uploads.value.filter(x => x.id !== id); + let text = i18n.ts.uploadFailedDescription; + if (xhr.status == 413) { + // the file was too large + text = i18n.ts.uploadFailedSize; + } else if (xhr.response?.error?.message != null) { + text = xhr.response?.error?.message; + } + alert({ type: 'error', - title: 'Failed to upload', - text: `${JSON.stringify(ev.target?.response)}, ${JSON.stringify(xhr.response)}`, + title: i18n.ts.uploadFailed, + text, }); reject();