Update upload.go

This commit is contained in:
ZizzyDizzyMC 2021-02-09 23:07:18 -05:00
parent cb69d98032
commit 2624427b6c
1 changed files with 3 additions and 3 deletions

View File

@ -61,7 +61,6 @@ func uploadPostHandler(c web.C, w http.ResponseWriter, r *http.Request) {
uploadHeaderProcess(r, &upReq)
contentType := r.Header.Get("Content-Type")
if strings.HasPrefix(contentType, "multipart/form-data") {
file, headers, err := r.FormFile("file")
if err != nil {
@ -95,7 +94,7 @@ func uploadPostHandler(c web.C, w http.ResponseWriter, r *http.Request) {
if r.PostFormValue("randomize") == "true" {
upReq.randomBarename = true
}
upReq.srcIp = r.Header.Get("X-Forwarded-For")
upload, err := processUpload(upReq)
if strings.EqualFold("application/json", r.Header.Get("Accept")) {
@ -130,6 +129,7 @@ func uploadPutHandler(c web.C, w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
upReq.filename = c.URLParams["name"]
upReq.src = http.MaxBytesReader(w, r.Body, Config.maxSize)
upReq.srcIp = r.Header.Get("X-Forwarded-For")
upload, err := processUpload(upReq)
if strings.EqualFold("application/json", r.Header.Get("Accept")) {
@ -201,6 +201,7 @@ func uploadRemote(c web.C, w http.ResponseWriter, r *http.Request) {
upReq.accessKey = r.FormValue(accessKeyParamName)
upReq.randomBarename = r.FormValue("randomize") == "yes"
upReq.expiry = parseExpiry(r.FormValue("expiry"))
upReq.srcIp = r.Header.Get("X-Forwarded-For")
upload, err := processUpload(upReq)
if strings.EqualFold("application/json", r.Header.Get("Accept")) {
@ -233,7 +234,6 @@ func uploadHeaderProcess(r *http.Request, upReq *UploadRequest) {
upReq.deleteKey = r.Header.Get("Linx-Delete-Key")
upReq.accessKey = r.Header.Get(accessKeyHeaderName)
upReq.srcIp = r.Header.get("X-Forwarded-For")
// Get seconds until expiry. Non-integer responses never expire.
expStr := r.Header.Get("Linx-Expiry")
upReq.expiry = parseExpiry(expStr)