Limit file upload size
This commit is contained in:
@@ -16,6 +16,7 @@ type Config struct {
|
||||
FileRoot string
|
||||
Auth bool
|
||||
AuthLifetime time.Duration
|
||||
MaxFileSize int64
|
||||
}
|
||||
|
||||
func New() Config {
|
||||
@@ -35,6 +36,7 @@ func New() Config {
|
||||
as.Append(args.STRING, "drivertype", "database driver to use", "boltdb")
|
||||
as.Append(args.BOOL, "auth", "check for authorized access", false)
|
||||
as.Append(args.DURATION, "authlifetime", "duration auth is valid for", time.Hour)
|
||||
as.Append(args.INT, "max-file-size", "max file size for uploads in bytes", 50*(1<<20))
|
||||
|
||||
if err := as.Parse(); err != nil {
|
||||
panic(err)
|
||||
@@ -49,5 +51,6 @@ func New() Config {
|
||||
DriverType: as.GetString("drivertype"),
|
||||
Auth: as.GetBool("auth"),
|
||||
AuthLifetime: as.GetDuration("authlifetime"),
|
||||
MaxFileSize: int64(as.GetInt("max-file-size")),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user