Update upload.go
This commit is contained in:
parent
7635abf2dc
commit
17441020c2
35
upload.go
35
upload.go
|
@ -95,6 +95,16 @@ func uploadPostHandler(c web.C, w http.ResponseWriter, r *http.Request) {
|
||||||
upReq.randomBarename = true
|
upReq.randomBarename = true
|
||||||
}
|
}
|
||||||
upReq.srcIp = r.Header.Get("X-Forwarded-For")
|
upReq.srcIp = r.Header.Get("X-Forwarded-For")
|
||||||
|
|
||||||
|
if len(r.Header.Get("Content-Length")) > 0 {
|
||||||
|
i, err := strconv.ParseInt(r.Header.Get("Content-Length"), 10, 64)
|
||||||
|
if err == nil {
|
||||||
|
if i > Config.maxSize {
|
||||||
|
upReq.size = i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
upload, err := processUpload(upReq)
|
upload, err := processUpload(upReq)
|
||||||
|
|
||||||
if strings.EqualFold("application/json", r.Header.Get("Accept")) {
|
if strings.EqualFold("application/json", r.Header.Get("Accept")) {
|
||||||
|
@ -126,6 +136,15 @@ func uploadPutHandler(c web.C, w http.ResponseWriter, r *http.Request) {
|
||||||
upReq := UploadRequest{}
|
upReq := UploadRequest{}
|
||||||
uploadHeaderProcess(r, &upReq)
|
uploadHeaderProcess(r, &upReq)
|
||||||
|
|
||||||
|
if len(r.Header.Get("Content-Length")) > 0 {
|
||||||
|
i, err := strconv.ParseInt(r.Header.Get("Content-Length"), 10, 64)
|
||||||
|
if err == nil {
|
||||||
|
if i > Config.maxSize {
|
||||||
|
upReq.size = i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
defer r.Body.Close()
|
defer r.Body.Close()
|
||||||
upReq.filename = c.URLParams["name"]
|
upReq.filename = c.URLParams["name"]
|
||||||
upReq.src = http.MaxBytesReader(w, r.Body, Config.maxSize)
|
upReq.src = http.MaxBytesReader(w, r.Body, Config.maxSize)
|
||||||
|
@ -194,6 +213,14 @@ func uploadRemote(c web.C, w http.ResponseWriter, r *http.Request) {
|
||||||
oopsHandler(c, w, r, RespAUTO, "Could not retrieve URL")
|
oopsHandler(c, w, r, RespAUTO, "Could not retrieve URL")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if len(r.Header.Get("Content-Length")) > 0 {
|
||||||
|
i, err := strconv.ParseInt(r.Header.Get("Content-Length"), 10, 64)
|
||||||
|
if err == nil {
|
||||||
|
if i > Config.maxSize {
|
||||||
|
upReq.size = i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
upReq.filename = filepath.Base(grabUrl.Path)
|
upReq.filename = filepath.Base(grabUrl.Path)
|
||||||
upReq.src = http.MaxBytesReader(w, resp.Body, Config.maxSize)
|
upReq.src = http.MaxBytesReader(w, resp.Body, Config.maxSize)
|
||||||
|
@ -228,14 +255,6 @@ func uploadRemote(c web.C, w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func uploadHeaderProcess(r *http.Request, upReq *UploadRequest) {
|
func uploadHeaderProcess(r *http.Request, upReq *UploadRequest) {
|
||||||
if len(r.Header.Get("Content-Length")) > 0 {
|
|
||||||
i, err := strconv.ParseInt(r.Header.Get("Content-Length"), 10, 64)
|
|
||||||
if err == nil {
|
|
||||||
if i > Config.maxSize {
|
|
||||||
upReq.size = i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if r.Header.Get("Linx-Randomize") == "yes" {
|
if r.Header.Get("Linx-Randomize") == "yes" {
|
||||||
upReq.randomBarename = true
|
upReq.randomBarename = true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue