Fix timeout error when uploading large files
This commit is contained in:
parent
273d5fe74c
commit
ebb9a7bfb6
3 changed files with 5 additions and 3 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
5
main.go
5
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 {
|
||||
|
|
Loading…
Reference in a new issue