diff options
-rw-r--r-- | main.go | 7 | ||||
-rw-r--r-- | storage.go | 4 |
2 files changed, 6 insertions, 5 deletions
@@ -69,12 +69,12 @@ func main() { listenHttps := flag.String("https", "", "address to listen on for HTTPS") cert := flag.String("cert", "", "path to TLS certificate (for HTTPS)") key := flag.String("key", "", "path to TLS key (for HTTPS)") - maxSize := flag.Int64("max-size", 50*1024*1024, "max filesize in bytes") + maxSize := flag.Int64("max-size", DefaultMaxSize, "max filesize in bytes") filterMime := flag.String("filter-mime", "application/x-dosexec,application/x-msdos-program", "comma-separated list of filtered MIME types") filterExt := flag.String("filter-ext", "exe,dll,msi,scr,com,pif", "comma-separated list of filtered file extensions") whitelist := flag.Bool("whitelist", false, "use filter as a whitelist instead of blacklist") grill := flag.Bool("grill", false, "enable grills") - idLength := flag.Int("id-length", 6, "length of uploaded file IDs") + idLength := flag.Int("id-length", DefaultIdLength, "length of uploaded file IDs") idCharset := flag.String("id-charset", "", "charset for uploaded file IDs (default lowercase letters a-z)") flag.Parse() @@ -83,11 +83,12 @@ func main() { initWebsite() - storage = NewStorage("upload", *maxSize) + storage = NewStorage("upload") storage.FilterExt = strings.Split(*filterExt, ",") storage.FilterMime = strings.Split(*filterMime, ",") storage.Whitelist = *whitelist storage.IdLength = *idLength + storage.MaxSize = *maxSize if *idCharset != "" { storage.IdCharset = *idCharset } @@ -49,7 +49,7 @@ type ErrNotFound struct{ Name string } func (e ErrNotFound) Error() string { return "file " + e.Name + " not found" } -func NewStorage(folder string, maxSize int64) *Storage { +func NewStorage(folder string) *Storage { if err := os.MkdirAll(path.Join(folder, "temp"), 0755); err != nil { panic(err) } @@ -64,7 +64,7 @@ func NewStorage(folder string, maxSize int64) *Storage { Folder: folder, IdCharset: DefaultIdCharset, IdLength: DefaultIdLength, - MaxSize: maxSize, + MaxSize: DefaultMaxSize, } } |