From 094a4c211022b9446ef988c74c546ad6efb09722 Mon Sep 17 00:00:00 2001 From: Wolfy-J Date: Sun, 10 Jun 2018 17:18:23 +0300 Subject: http service --- http/uploads_config.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'http/uploads_config.go') 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 { -- cgit v1.2.3