Skip to content

Commit

Permalink
change status code in the s3store
Browse files Browse the repository at this point in the history
  • Loading branch information
peifan-tes committed Aug 25, 2020
1 parent 4fd795a commit b346401
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/s3store/s3store.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import (
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -898,12 +899,12 @@ func (store S3Store) metadataKeyWithPrefix(key string) *string {
func (store S3Store) validate(info handler.FileInfo) error {
// an upload larger than MaxObjectSize must throw an error
if info.Size > store.MaxObjectSize {
return fmt.Errorf("s3store: upload size of %v bytes exceeds MaxObjectSize of %v bytes", info.Size, store.MaxObjectSize)
return handler.NewHTTPError(fmt.Errorf("s3store: upload size of %v bytes exceeds MaxObjectSize of %v bytes", info.Size, store.MaxObjectSize), http.StatusForbidden)
}

filename, ok := info.MetaData["filename"]
if !ok || strings.Trim(filepath.Base(filename), " ") == "" {
return fmt.Errorf("s3store: nonempty filename in upload metadata is required")
return handler.NewHTTPError(fmt.Errorf("s3store: nonempty filename in upload metadata is required"), http.StatusBadRequest)
}

return nil
Expand Down

0 comments on commit b346401

Please sign in to comment.