remove any temporary files associated with a Form, fixes #347.
This commit is contained in:
parent
a03b29ba01
commit
792b1ac111
@ -166,7 +166,13 @@ func New(conf *config.Server, webSocketHandler types.WebSocketHandler, desktop t
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
r.ParseMultipartForm(32 << 20)
|
err = r.ParseMultipartForm(32 << 20)
|
||||||
|
if err != nil || r.MultipartForm == nil {
|
||||||
|
logger.Warn().Err(err).Msg("failed to parse multipart form")
|
||||||
|
http.Error(w, "error parsing form", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for _, formheader := range r.MultipartForm.File["files"] {
|
for _, formheader := range r.MultipartForm.File["files"] {
|
||||||
filePath := webSocketHandler.FileTransferPath(formheader.Filename)
|
filePath := webSocketHandler.FileTransferPath(formheader.Filename)
|
||||||
|
|
||||||
@ -187,6 +193,11 @@ func New(conf *config.Server, webSocketHandler types.WebSocketHandler, desktop t
|
|||||||
|
|
||||||
io.Copy(f, formfile)
|
io.Copy(f, formfile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = r.MultipartForm.RemoveAll()
|
||||||
|
if err != nil {
|
||||||
|
logger.Warn().Err(err).Msg("failed to remove multipart form")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user