From 835f9374f6d9496b005d054f2a33e851b87a1fa4 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Wed, 13 Feb 2019 17:58:44 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=B0=20=D0=BA=D0=BB=D0=B8=D0=B5?= =?UTF-8?q?=D0=BD=D1=82=D0=B5=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=D0=BA=D0=B8=20maxUploadFileSize?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/api/misc.js | 2 +- client/api/reader.js | 9 +++++---- client/components/Reader/Reader.vue | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/client/api/misc.js b/client/api/misc.js index dee0c134..94ebdab5 100644 --- a/client/api/misc.js +++ b/client/api/misc.js @@ -6,7 +6,7 @@ const api = axios.create({ class Misc { async loadConfig() { - const response = await api.post('/config', {params: ['name', 'version', 'mode']}); + const response = await api.post('/config', {params: ['name', 'version', 'mode', 'maxUploadFileSize']}); return response.data; } } diff --git a/client/api/reader.js b/client/api/reader.js index e6d73773..8031e10a 100644 --- a/client/api/reader.js +++ b/client/api/reader.js @@ -1,7 +1,6 @@ import axios from 'axios'; import {sleep} from '../share/utils'; -const maxFileUploadSize = 50*1024*1024; const api = axios.create({ baseURL: '/api/reader' }); @@ -75,9 +74,11 @@ class Reader { return await axios.get(url, options); } - async uploadFile(file, callback) { - if (file.size > maxFileUploadSize) - throw new Error(`Размер файла превышает ${maxFileUploadSize} байт`); + async uploadFile(file, maxUploadFileSize, callback) { + if (!maxUploadFileSize) + maxUploadFileSize = 10*1024*1024; + if (file.size > maxUploadFileSize) + throw new Error(`Размер файла превышает ${maxUploadFileSize} байт`); let formData = new FormData(); formData.append('file', file); diff --git a/client/components/Reader/Reader.vue b/client/components/Reader/Reader.vue index 31a55305..d4fb7e8e 100644 --- a/client/components/Reader/Reader.vue +++ b/client/components/Reader/Reader.vue @@ -168,6 +168,7 @@ class Reader extends Vue { this.commit = this.$store.commit; this.dispatch = this.$store.dispatch; this.reader = this.$store.state.reader; + this.config = this.$store.state.config; this.$root.addKeyHook(this.keyHook); @@ -713,7 +714,7 @@ class Reader extends Vue { progress.show(); progress.setState({state: 'upload'}); - const url = await readerApi.uploadFile(opts.file, (state) => { + const url = await readerApi.uploadFile(opts.file, this.config.maxUploadFileSize, (state) => { progress.setState(state); });