diff options
author | Wolfy-J <[email protected]> | 2018-06-10 17:18:23 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-06-10 17:18:23 +0300 |
commit | 094a4c211022b9446ef988c74c546ad6efb09722 (patch) | |
tree | 603ade627491960108154d6301868c9b881cd101 /http/uploads_config.go | |
parent | 232aa8f3c20a060e556ab431467f4f7b3f83bfbf (diff) |
http service
Diffstat (limited to 'http/uploads_config.go')
-rw-r--r-- | http/uploads_config.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/http/uploads_config.go b/http/uploads_config.go index ac80723f..715de69a 100644 --- a/http/uploads_config.go +++ b/http/uploads_config.go @@ -3,6 +3,7 @@ package http import ( "strings" "path" + "os" ) // UploadsConfig describes file location and controls access to them. @@ -15,8 +16,17 @@ type UploadsConfig struct { Forbid []string } +// TmpDir returns temporary directory. +func (cfg *UploadsConfig) TmpDir() string { + if cfg.Dir != "" { + return cfg.Dir + } + + return os.TempDir() +} + // Forbid must return true if file extension is not allowed for the upload. -func (cfg UploadsConfig) Forbids(filename string) bool { +func (cfg *UploadsConfig) Forbids(filename string) bool { ext := strings.ToLower(path.Ext(filename)) for _, v := range cfg.Forbid { |