Skip to content

Commit e51eb1d

Browse files
committed
Delete guest tokens after usage
1 parent 373d9d1 commit e51eb1d

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

internal/webserver/fileupload/FileUpload.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
package fileupload
22

33
import (
4+
"io"
5+
"net/http"
6+
"strconv"
7+
"time"
8+
49
"github.com/forceu/gokapi/internal/configuration"
510
"github.com/forceu/gokapi/internal/configuration/database"
611
"github.com/forceu/gokapi/internal/models"
712
"github.com/forceu/gokapi/internal/storage"
813
"github.com/forceu/gokapi/internal/storage/chunking"
9-
"io"
10-
"net/http"
11-
"strconv"
12-
"time"
14+
"github.com/forceu/gokapi/internal/webserver/guestupload"
1315
)
1416

1517
// Process processes a file upload request
@@ -83,6 +85,13 @@ func CompleteChunk(w http.ResponseWriter, r *http.Request, isApiCall bool) error
8385
return err
8486
}
8587
_, _ = io.WriteString(w, result.ToJsonResult(config.ExternalUrl))
88+
89+
// If an UploadToken was used, delete it
90+
tokens, ok := r.URL.Query()["token"]
91+
if ok && guestupload.IsValidUploadToken(tokens[0]) {
92+
guestupload.DeleteUploadToken(tokens[0])
93+
}
94+
8695
return nil
8796
}
8897

0 commit comments

Comments
 (0)