@@ -39,6 +39,7 @@ type Upload struct {
39
39
NotifyURL string `json:"notify_url,omitempty"`
40
40
NotifyMethod string `json:"notify_method,omitempty"`
41
41
CreateUuidDir bool `json:"create_uuid_dir,omitempty"`
42
+ DestDirFieldName string `json:"dest_dir_field_name,omitempty"`
42
43
43
44
MyTlsSetting struct {
44
45
InsecureSkipVerify bool `json:"insecure,omitempty"`
@@ -66,10 +67,10 @@ func (u *Upload) Provision(ctx caddy.Context) error {
66
67
67
68
repl := caddy .NewReplacer ()
68
69
69
- if u .DestDir == "" {
70
+ if u .DestDir == "" && u . DestDirFieldName == "" {
70
71
u .logger .Error ("Provision" ,
71
- zap .String ("msg" , "no Destination Directory specified (dest_dir)" ))
72
- return fmt .Errorf ("no Destination Directory specified (dest_dir)" )
72
+ zap .String ("msg" , "no Destination Directory specified (dest_dir or dest_dir_field_name )" ))
73
+ return fmt .Errorf ("no Destination Directory specified (dest_dir or dest_dir_field_name )" )
73
74
}
74
75
75
76
if u .RootDir == "" {
@@ -171,6 +172,7 @@ func (u *Upload) Provision(ctx caddy.Context) error {
171
172
zap .Bool ("CreateUuidDir" , u .CreateUuidDir ),
172
173
zap .String ("capath" , u .MyTlsSetting .CAPath ),
173
174
zap .Bool ("insecure" , u .MyTlsSetting .InsecureSkipVerify ),
175
+ zap .String ("dest_dir_field_name" , u .DestDirFieldName ),
174
176
)
175
177
176
178
return nil
@@ -239,6 +241,10 @@ func (u Upload) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp
239
241
}
240
242
}
241
243
244
+ if u .DestDirFieldName != "" {
245
+ u .DestDir = r .FormValue (u .DestDirFieldName )
246
+ }
247
+
242
248
concatDir := caddyhttp .SanitizedPathJoin (u .RootDir , u .DestDir )
243
249
244
250
if u .CreateUuidDir {
0 commit comments