fix hard-coded frontend max_upload_size validation (#20)
This commit is contained in:
parent
cb8d61538d
commit
20bf93c86d
4 changed files with 25 additions and 21 deletions
|
@ -204,7 +204,9 @@ func (a *App) indexHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
// HTTP handler for /upload
|
// HTTP handler for /upload
|
||||||
func (a *App) uploadHandler(w http.ResponseWriter, r *http.Request) {
|
func (a *App) uploadHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method == "GET" {
|
if r.Method == "GET" {
|
||||||
ctx := &struct{}{}
|
ctx := map[string]interface{}{
|
||||||
|
"MAX_UPLOAD_SIZE": a.Config.Server.MaxUploadSize,
|
||||||
|
}
|
||||||
a.render("upload", w, ctx)
|
a.render("upload", w, ctx)
|
||||||
} else if r.Method == "POST" {
|
} else if r.Method == "POST" {
|
||||||
r.ParseMultipartForm(a.Config.Server.MaxUploadSize)
|
r.ParseMultipartForm(a.Config.Server.MaxUploadSize)
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,8 +1,9 @@
|
||||||
// common variables
|
// common variables
|
||||||
|
let configMaxUploadSize = window['MAX_UPLOAD_SIZE'];
|
||||||
let iBytesUploaded = 0
|
let iBytesUploaded = 0
|
||||||
let iBytesTotal = 0
|
let iBytesTotal = 0
|
||||||
let iPreviousBytesLoaded = 0
|
let iPreviousBytesLoaded = 0
|
||||||
let iMaxFilesize = 104857600 // 100MB
|
let iMaxFilesize = configMaxUploadSize ? (+configMaxUploadSize) : (100 * 1024 * 1024); // 100MB
|
||||||
let timer = 0
|
let timer = 0
|
||||||
let uploadInProgress = 'n/a'
|
let uploadInProgress = 'n/a'
|
||||||
let isProcessing = false
|
let isProcessing = false
|
||||||
|
|
|
@ -36,5 +36,6 @@
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{define "scripts"}}
|
{{define "scripts"}}
|
||||||
|
<script>window['MAX_UPLOAD_SIZE'] = '{{.MAX_UPLOAD_SIZE}}';</script>
|
||||||
<script type="application/javascript" src="/static/upload.js"></script>
|
<script type="application/javascript" src="/static/upload.js"></script>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
Loading…
Reference in a new issue