From 9666f2e5bf2140899114dbec0b261109cc6f487f Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 23 May 2015 12:15:13 -0700 Subject: [PATCH] Relax minium object size limit, one can really upload a 0byte file For example ~~~ $ mc ls https://s3.amazonaws.com/ferenginar/test.go [2015-05-23 12:02:06 PDT] 0B test.go $ curl -i -X HEAD https://s3.amazonaws.com/ferenginar/test.go HTTP/1.1 200 OK x-amz-id-2: ZMWLriPH+uQJ8IsaMHmuNOU/FXvdSq+s6O7ugUI9hZ695XJTNAZ1utKxh03w5Jcf x-amz-request-id: F5A11F533B74DD8F Date: Sat, 23 May 2015 19:19:29 GMT Last-Modified: Sat, 23 May 2015 19:02:06 GMT ETag: "d41d8cd98f00b204e9800998ecf8427e" Accept-Ranges: bytes Content-Type: binary/octet-stream Content-Length: 0 Server: AmazonS3 ~~~ --- pkg/api/api_object_handlers.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/pkg/api/api_object_handlers.go b/pkg/api/api_object_handlers.go index 0c7a59281..d7e9aba3a 100644 --- a/pkg/api/api_object_handlers.go +++ b/pkg/api/api_object_handlers.go @@ -168,10 +168,19 @@ func (server *minioAPI) putObjectHandler(w http.ResponseWriter, req *http.Reques return } /// minimum Upload size for objects in a single operation - if isMinObjectSize(size) { - writeErrorResponse(w, req, EntityTooSmall, acceptsContentType, req.URL.Path) - return - } + // + // Surprisingly while Amazon in their document states that S3 objects have 1byte + // as the minimum limit, they do not seem to enforce it one can successfully + // create a 0byte file using a regular putObject() operation + // + // For example take a look at :- + // + // $ mc ls https://s3.amazonaws.com/ferenginar/test.go + // + // if isMinObjectSize(size) { + // writeErrorResponse(w, req, EntityTooSmall, acceptsContentType, req.URL.Path) + // return + // } sizeInt64, err := strconv.ParseInt(size, 10, 64) if err != nil { writeErrorResponse(w, req, InvalidRequest, acceptsContentType, req.URL.Path) @@ -275,15 +284,6 @@ func (server *minioAPI) putObjectPartHandler(w http.ResponseWriter, req *http.Re return } - // last part can be less than < 5MB so we need to figure out a way to handle it first - // and then enable below code (y4m4) - // - /// minimum Upload size for multipart objects in a single operation - // if isMinMultipartObjectSize(size) { - // writeErrorResponse(w, req, EntityTooSmall, acceptsContentType, req.URL.Path) - // return - // } - sizeInt64, err := strconv.ParseInt(size, 10, 64) if err != nil { writeErrorResponse(w, req, InvalidRequest, acceptsContentType, req.URL.Path)