mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-27 18:40:39 +00:00
upload-limit v0.1
This commit is contained in:
Vendored
+25
-4
@@ -10,7 +10,7 @@ const Helpers = {
|
||||
|
||||
Vue.prototype.$updateText = debounce(function (route, name, value) {
|
||||
|
||||
let enableEmptyInput = ['mimetypes_blacklist' , 'google_analytics']
|
||||
let enableEmptyInput = ['mimetypes_blacklist' , 'google_analytics' , 'upload_limit']
|
||||
|
||||
if (value === '' && !enableEmptyInput.includes(name)) return
|
||||
|
||||
@@ -148,8 +148,8 @@ const Helpers = {
|
||||
if (error.response.status === 500)
|
||||
isNotGeneralError = false
|
||||
|
||||
//Break if mimetype of file is in blacklist
|
||||
if(error.response.status === 415)
|
||||
//Break if mimetype of file is in blacklist or file size exceed upload limit
|
||||
if(error.response.status === 415 || 413)
|
||||
isNotGeneralError = false
|
||||
|
||||
// Show Error
|
||||
@@ -177,7 +177,7 @@ const Helpers = {
|
||||
|
||||
if (files.length == 0) return
|
||||
|
||||
if (!this.$checkFileMimetype(files)) return
|
||||
if (!this.$checkFileMimetype(files) || !this.$checkUploadLimit(files)) return
|
||||
|
||||
this.$handleUploading(files, undefined)
|
||||
}
|
||||
@@ -307,6 +307,27 @@ const Helpers = {
|
||||
}
|
||||
return validated
|
||||
}
|
||||
Vue.prototype.$checkUploadLimit = function (files) {
|
||||
let uploadLimit = store.getters.config.uploadLimit
|
||||
let validate = true
|
||||
|
||||
for (let i = 0 ; i<files.length; i++ ) {
|
||||
if(files[i].size > uploadLimit * 1000000 ) {
|
||||
validate = false
|
||||
events.$emit('alert:open', {
|
||||
emoji: '😬😬😬',
|
||||
title: i18n.t('popup_upload_limit.title'),
|
||||
message: i18n.t('popup_upload_limit.message', {uploadLimit: uploadLimit}),
|
||||
})
|
||||
break
|
||||
}else {
|
||||
validate = true
|
||||
}
|
||||
}
|
||||
|
||||
return validate
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user