mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
s3: report error to s3 when updating an object but it is already a directory
fix https://github.com/chrislusf/seaweedfs/issues/1545
This commit is contained in:
parent
7fc98da709
commit
b3aa2fab9a
|
@ -5,12 +5,13 @@ import (
|
|||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"github.com/chrislusf/seaweedfs/weed/s3api/s3err"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/chrislusf/seaweedfs/weed/s3api/s3err"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||
|
@ -333,7 +334,7 @@ func (s3a *S3ApiServer) putToFiler(r *http.Request, uploadUrl string, dataReader
|
|||
}
|
||||
if ret.Error != "" {
|
||||
glog.Errorf("upload to filer error: %v", ret.Error)
|
||||
return "", s3err.ErrInternalError
|
||||
return "", filerErrorToS3Error(ret.Error)
|
||||
}
|
||||
|
||||
return etag, s3err.ErrNone
|
||||
|
@ -359,3 +360,10 @@ func getBucketAndObject(r *http.Request) (bucket, object string) {
|
|||
|
||||
return
|
||||
}
|
||||
|
||||
func filerErrorToS3Error(errString string) s3err.ErrorCode {
|
||||
if strings.HasPrefix(errString, "existing ") && strings.HasSuffix(errString, "is a directory") {
|
||||
return s3err.ErrExistingObjectIsDirectory
|
||||
}
|
||||
return s3err.ErrInternalError
|
||||
}
|
||||
|
|
|
@ -92,6 +92,8 @@ const (
|
|||
ErrMissingDateHeader
|
||||
ErrInvalidRequest
|
||||
ErrNotImplemented
|
||||
|
||||
ErrExistingObjectIsDirectory
|
||||
)
|
||||
|
||||
// error code to APIError structure, these fields carry respective
|
||||
|
@ -344,6 +346,11 @@ var errorCodeResponse = map[ErrorCode]APIError{
|
|||
Description: "A header you provided implies functionality that is not implemented",
|
||||
HTTPStatusCode: http.StatusNotImplemented,
|
||||
},
|
||||
ErrExistingObjectIsDirectory: {
|
||||
Code: "ExistingObjectIsDirectory",
|
||||
Description: "Existing Object is a directory.",
|
||||
HTTPStatusCode: http.StatusConflict,
|
||||
},
|
||||
}
|
||||
|
||||
// GetAPIError provides API Error for input API error code.
|
||||
|
|
Loading…
Reference in a new issue