diff --git a/README.md b/README.md index 8cf8694..2277b54 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ The application can be configured with the following environment variables: - `IAM_ENDPOINT`: Endpoint for IAM role retrieving (Can be blank for AWS) - `SSE_TYPE`: Specified server side encrpytion (defaults blank) Valid values can be `SSE`, `KMS`, `SSE-C` all others values don't enable the SSE - `SSE_KEY`: The key needed for SSE method (only for `KMS` and `SSE-C`) +- `TIMEOUT`: The read timout and write timout in second (default to `600` - 10 minute) ### Build and Run Locally diff --git a/internal/app/s3manager/create_object.go b/internal/app/s3manager/create_object.go index 266792d..0169875 100644 --- a/internal/app/s3manager/create_object.go +++ b/internal/app/s3manager/create_object.go @@ -16,7 +16,7 @@ func HandleCreateObject(s3 S3, sseInfo SSEType) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { bucketName := mux.Vars(r)["bucketName"] - err := r.ParseMultipartForm(0) + err := r.ParseMultipartForm(32 << 20) // 32 Mb if err != nil { handleHTTPError(w, fmt.Errorf("error parsing multipart form: %w", err)) return diff --git a/main.go b/main.go index 3295fac..cc95a23 100644 --- a/main.go +++ b/main.go @@ -18,8 +18,6 @@ import ( "github.com/spf13/viper" ) -const serverTimeout = 5 * time.Second - //go:embed web/template var templateFS embed.FS @@ -74,6 +72,9 @@ func main() { sseType := s3manager.SSEType{Type: viper.GetString("SSE_TYPE"), Key: viper.GetString("SSE_KEY")} + viper.SetDefault("TIMEOUT", 600) + serverTimeout := time.Duration(viper.GetInt32("TIMEOUT")) * time.Second + // Set up templates templates, err := fs.Sub(templateFS, "web/template") if err != nil {