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); });