Skip to content

Commit 4839b10

Browse files
committed
Add uuiddir as variable. fix #14
1 parent 9780828 commit 4839b10

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

.github/workflows/go.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ jobs:
1616
- name: Set up Go
1717
uses: actions/setup-go@v3
1818
with:
19-
go-version: 1.20.7
19+
go-version: 1.20.10
2020

2121
- name: Download xcaddy
22-
run: curl -vLO https://github.com/caddyserver/xcaddy/releases/download/v0.3.4/xcaddy_0.3.4_linux_amd64.tar.gz
22+
run: curl -vLO https://github.com/caddyserver/xcaddy/releases/download/v0.3.4/xcaddy_0.3.5_linux_amd64.tar.gz
2323

2424
- name: Extract xcaddy
25-
run: tar xfvz xcaddy_0.3.4_linux_amd64.tar.gz
25+
run: tar xfvz xcaddy_0.3.5_linux_amd64.tar.gz
2626

2727
- name: Build
2828
run: ./xcaddy build --with github.com/kirsch33/realip --with github.com/caddyserver/jsonc-adapter --with github.com/git001/caddyv2-upload

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
FROM ubuntu:latest
22

3-
ENV XCADDY_VERSION=0.3.4 \
4-
GOLANG_VERSION=20.7 \
3+
ENV XCADDY_VERSION=0.3.5 \
4+
GOLANG_VERSION=20.10 \
55
APPPORT=:2011 \
6-
UPLOADER_VERSION=0.14
6+
UPLOADER_VERSION=0.15
77

88
COPY docker-files /
99

README.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ The following Variables will be added to the request flow
101101
|**http.upload.directory**
102102
|The directory where the file is uploaded
103103

104+
|**http.upload.uuiddir**
105+
|The name of the random directory created if `create_uuid_dir` is enabled
106+
104107
|===
105108

106109
=== JSON

docker-files/opt/webroot/templates/upload-resp-template.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ http.upload.filename: {{placeholder "http.upload.filename"}}
88
http.upload.filesize: {{placeholder "http.upload.filesize"}}
99
http.upload.directory: {{placeholder "http.upload.directory"}}
1010

11+
http.upload.uuiddir: {{placeholder "http.upload.uuiddir"}}
12+

upload.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
)
1717

1818
const (
19-
Version = "0.14"
19+
Version = "0.15"
2020
)
2121

2222
func init() {
@@ -235,18 +235,19 @@ func (u Upload) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp
235235
concatDir := caddyhttp.SanitizedPathJoin(u.RootDir, u.DestDir)
236236

237237
if u.CreateUuidDir {
238-
uuidDir := uuid.New()
238+
uuidDir := uuid.New().String()
239239

240240
// It's very unlikely that the uuidDir already exists, but just in case
241241
for {
242-
if _, err := os.Stat(caddyhttp.SanitizedPathJoin(concatDir, uuidDir.String())); os.IsNotExist(err) {
242+
if _, err := os.Stat(caddyhttp.SanitizedPathJoin(concatDir, uuidDir)); os.IsNotExist(err) {
243243
break
244244
} else {
245-
uuidDir = uuid.New()
245+
uuidDir = uuid.New().String()
246246
}
247247
}
248248

249-
concatDir = caddyhttp.SanitizedPathJoin(concatDir, uuidDir.String())
249+
concatDir = caddyhttp.SanitizedPathJoin(concatDir, uuidDir)
250+
repl.Set("http.upload.uuiddir", uuidDir)
250251
}
251252

252253
if err := os.MkdirAll(concatDir, 0755); err != nil {

0 commit comments

Comments
 (0)