maxObjectSize and minObjectSize limitation added at putObjectHandler()

Put() replies back with

   - EntityTooLarge with > 5GB in single PUT operation
   - EntityTooSmall with < 1B in single PUT operation
   - IncompleteBody with ho Content-Length found in HTTP request header
This commit is contained in:
Harshavardhana
2015-04-29 02:19:51 -07:00
parent c14496f928
commit b18bb230da
2 changed files with 64 additions and 1 deletions
+14 -1
View File
@@ -139,7 +139,7 @@ func (server *minioAPI) putObjectHandler(w http.ResponseWriter, req *http.Reques
return
}
// handle PublicRead ACL here
// handle ACL's here at bucket level
if !server.isValidOp(w, req, acceptsContentType) {
return
}
@@ -155,6 +155,19 @@ func (server *minioAPI) putObjectHandler(w http.ResponseWriter, req *http.Reques
writeErrorResponse(w, req, InvalidDigest, acceptsContentType, req.URL.Path)
return
}
size := req.Header.Get("Content-Length")
if size == "" {
writeErrorResponse(w, req, IncompleteBody, acceptsContentType, req.URL.Path)
return
}
if isMaxObjectSize(size) {
writeErrorResponse(w, req, EntityTooLarge, acceptsContentType, req.URL.Path)
return
}
if isMinObjectSize(size) {
writeErrorResponse(w, req, EntityTooSmall, acceptsContentType, req.URL.Path)
return
}
err := server.driver.CreateObject(bucket, object, "", md5, req.Body)
switch err := iodine.ToError(err).(type) {
case nil: