Skip to content

Commit

Permalink
Cleanup uploaded file close #13
Browse files Browse the repository at this point in the history
  • Loading branch information
git001 committed Sep 5, 2023
1 parent 4715610 commit 9780828
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM ubuntu:latest
ENV XCADDY_VERSION=0.3.4 \
GOLANG_VERSION=20.7 \
APPPORT=:2011 \
UPLOADER_VERSION=0.13
UPLOADER_VERSION=0.14

COPY docker-files /

Expand Down
7 changes: 6 additions & 1 deletion upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

const (
Version = "0.13"
Version = "0.14"
)

func init() {
Expand Down Expand Up @@ -161,6 +161,7 @@ func (u *Upload) Provision(ctx caddy.Context) error {
zap.String("response_template", u.ResponseTemplate),
zap.String("notify_method", u.NotifyMethod),
zap.String("notify_url", u.NotifyURL),
zap.Bool("CreateUuidDir", u.CreateUuidDir),
zap.String("capath", u.MyTlsSetting.CAPath),
zap.Bool("insecure", u.MyTlsSetting.InsecureSkipVerify),
)
Expand Down Expand Up @@ -200,6 +201,10 @@ func (u Upload) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp
return caddyhttp.Error(http.StatusRequestEntityTooLarge, max_size_err)
}

// cleanup uploaded files see
// https://github.com/git001/caddyv2-upload/issues/13
defer r.MultipartForm.RemoveAll()

// FormFile returns the first file for the given file field key
// it also returns the FileHeader so we can get the Filename,
// the Header and the size of the file
Expand Down

0 comments on commit 9780828

Please sign in to comment.