|
|
@ -115,16 +115,22 @@ func (server *minioAPI) headObjectHandler(w http.ResponseWriter, req *http.Reque |
|
|
|
} |
|
|
|
} |
|
|
|
case drivers.ObjectNotFound: |
|
|
|
case drivers.ObjectNotFound: |
|
|
|
{ |
|
|
|
{ |
|
|
|
writeErrorResponse(w, req, NoSuchKey, acceptsContentType, req.URL.Path) |
|
|
|
error := getErrorCode(NoSuchKey) |
|
|
|
|
|
|
|
w.Header().Set("Server", "Minio") |
|
|
|
|
|
|
|
w.WriteHeader(error.HTTPStatusCode) |
|
|
|
} |
|
|
|
} |
|
|
|
case drivers.ObjectNameInvalid: |
|
|
|
case drivers.ObjectNameInvalid: |
|
|
|
{ |
|
|
|
{ |
|
|
|
writeErrorResponse(w, req, NoSuchKey, acceptsContentType, req.URL.Path) |
|
|
|
error := getErrorCode(NoSuchKey) |
|
|
|
|
|
|
|
w.Header().Set("Server", "Minio") |
|
|
|
|
|
|
|
w.WriteHeader(error.HTTPStatusCode) |
|
|
|
} |
|
|
|
} |
|
|
|
default: |
|
|
|
default: |
|
|
|
{ |
|
|
|
{ |
|
|
|
log.Error.Println(iodine.New(err, nil)) |
|
|
|
log.Error.Println(iodine.New(err, nil)) |
|
|
|
writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path) |
|
|
|
error := getErrorCode(InternalError) |
|
|
|
|
|
|
|
w.Header().Set("Server", "Minio") |
|
|
|
|
|
|
|
w.WriteHeader(error.HTTPStatusCode) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -227,18 +233,24 @@ func (server *minioAPI) newMultipartUploadHandler(w http.ResponseWriter, req *ht |
|
|
|
uploadID, err := server.driver.NewMultipartUpload(bucket, object, "") |
|
|
|
uploadID, err := server.driver.NewMultipartUpload(bucket, object, "") |
|
|
|
switch err := iodine.ToError(err).(type) { |
|
|
|
switch err := iodine.ToError(err).(type) { |
|
|
|
case nil: |
|
|
|
case nil: |
|
|
|
|
|
|
|
{ |
|
|
|
response := generateInitiateMultipartUploadResult(bucket, object, uploadID) |
|
|
|
response := generateInitiateMultipartUploadResult(bucket, object, uploadID) |
|
|
|
encodedSuccessResponse := encodeSuccessResponse(response, acceptsContentType) |
|
|
|
encodedSuccessResponse := encodeSuccessResponse(response, acceptsContentType) |
|
|
|
// write headers
|
|
|
|
// write headers
|
|
|
|
setCommonHeaders(w, getContentTypeString(acceptsContentType), len(encodedSuccessResponse)) |
|
|
|
setCommonHeaders(w, getContentTypeString(acceptsContentType), len(encodedSuccessResponse)) |
|
|
|
// write body
|
|
|
|
// write body
|
|
|
|
w.Write(encodedSuccessResponse) |
|
|
|
w.Write(encodedSuccessResponse) |
|
|
|
|
|
|
|
} |
|
|
|
case drivers.ObjectExists: |
|
|
|
case drivers.ObjectExists: |
|
|
|
|
|
|
|
{ |
|
|
|
writeErrorResponse(w, req, MethodNotAllowed, acceptsContentType, req.URL.Path) |
|
|
|
writeErrorResponse(w, req, MethodNotAllowed, acceptsContentType, req.URL.Path) |
|
|
|
|
|
|
|
} |
|
|
|
default: |
|
|
|
default: |
|
|
|
|
|
|
|
{ |
|
|
|
log.Println(iodine.New(err, nil)) |
|
|
|
log.Println(iodine.New(err, nil)) |
|
|
|
writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path) |
|
|
|
writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (server *minioAPI) putObjectPartHandler(w http.ResponseWriter, req *http.Request) { |
|
|
|
func (server *minioAPI) putObjectPartHandler(w http.ResponseWriter, req *http.Request) { |
|
|
@ -346,14 +358,20 @@ func (server *minioAPI) abortMultipartUploadHandler(w http.ResponseWriter, req * |
|
|
|
err := server.driver.AbortMultipartUpload(bucket, object, objectResourcesMetadata.UploadID) |
|
|
|
err := server.driver.AbortMultipartUpload(bucket, object, objectResourcesMetadata.UploadID) |
|
|
|
switch err := iodine.ToError(err).(type) { |
|
|
|
switch err := iodine.ToError(err).(type) { |
|
|
|
case nil: |
|
|
|
case nil: |
|
|
|
|
|
|
|
{ |
|
|
|
setCommonHeaders(w, getContentTypeString(acceptsContentType), 0) |
|
|
|
setCommonHeaders(w, getContentTypeString(acceptsContentType), 0) |
|
|
|
w.WriteHeader(http.StatusNoContent) |
|
|
|
w.WriteHeader(http.StatusNoContent) |
|
|
|
|
|
|
|
} |
|
|
|
case drivers.InvalidUploadID: |
|
|
|
case drivers.InvalidUploadID: |
|
|
|
|
|
|
|
{ |
|
|
|
writeErrorResponse(w, req, NoSuchUpload, acceptsContentType, req.URL.Path) |
|
|
|
writeErrorResponse(w, req, NoSuchUpload, acceptsContentType, req.URL.Path) |
|
|
|
|
|
|
|
} |
|
|
|
default: |
|
|
|
default: |
|
|
|
|
|
|
|
{ |
|
|
|
log.Println(err) |
|
|
|
log.Println(err) |
|
|
|
writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path) |
|
|
|
writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (server *minioAPI) listObjectPartsHandler(w http.ResponseWriter, req *http.Request) { |
|
|
|
func (server *minioAPI) listObjectPartsHandler(w http.ResponseWriter, req *http.Request) { |
|
|
@ -375,18 +393,24 @@ func (server *minioAPI) listObjectPartsHandler(w http.ResponseWriter, req *http. |
|
|
|
objectResourcesMetadata, err := server.driver.ListObjectParts(bucket, object, objectResourcesMetadata) |
|
|
|
objectResourcesMetadata, err := server.driver.ListObjectParts(bucket, object, objectResourcesMetadata) |
|
|
|
switch err := iodine.ToError(err).(type) { |
|
|
|
switch err := iodine.ToError(err).(type) { |
|
|
|
case nil: |
|
|
|
case nil: |
|
|
|
|
|
|
|
{ |
|
|
|
response := generateListPartsResult(objectResourcesMetadata) |
|
|
|
response := generateListPartsResult(objectResourcesMetadata) |
|
|
|
encodedSuccessResponse := encodeSuccessResponse(response, acceptsContentType) |
|
|
|
encodedSuccessResponse := encodeSuccessResponse(response, acceptsContentType) |
|
|
|
// write headers
|
|
|
|
// write headers
|
|
|
|
setCommonHeaders(w, getContentTypeString(acceptsContentType), len(encodedSuccessResponse)) |
|
|
|
setCommonHeaders(w, getContentTypeString(acceptsContentType), len(encodedSuccessResponse)) |
|
|
|
// write body
|
|
|
|
// write body
|
|
|
|
w.Write(encodedSuccessResponse) |
|
|
|
w.Write(encodedSuccessResponse) |
|
|
|
|
|
|
|
} |
|
|
|
case drivers.InvalidUploadID: |
|
|
|
case drivers.InvalidUploadID: |
|
|
|
|
|
|
|
{ |
|
|
|
writeErrorResponse(w, req, NoSuchUpload, acceptsContentType, req.URL.Path) |
|
|
|
writeErrorResponse(w, req, NoSuchUpload, acceptsContentType, req.URL.Path) |
|
|
|
|
|
|
|
} |
|
|
|
default: |
|
|
|
default: |
|
|
|
|
|
|
|
{ |
|
|
|
log.Println(err) |
|
|
|
log.Println(err) |
|
|
|
writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path) |
|
|
|
writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (server *minioAPI) completeMultipartUploadHandler(w http.ResponseWriter, req *http.Request) { |
|
|
|
func (server *minioAPI) completeMultipartUploadHandler(w http.ResponseWriter, req *http.Request) { |
|
|
@ -422,16 +446,22 @@ func (server *minioAPI) completeMultipartUploadHandler(w http.ResponseWriter, re |
|
|
|
etag, err := server.driver.CompleteMultipartUpload(bucket, object, objectResourcesMetadata.UploadID, partMap) |
|
|
|
etag, err := server.driver.CompleteMultipartUpload(bucket, object, objectResourcesMetadata.UploadID, partMap) |
|
|
|
switch err := iodine.ToError(err).(type) { |
|
|
|
switch err := iodine.ToError(err).(type) { |
|
|
|
case nil: |
|
|
|
case nil: |
|
|
|
|
|
|
|
{ |
|
|
|
response := generateCompleteMultpartUploadResult(bucket, object, "", etag) |
|
|
|
response := generateCompleteMultpartUploadResult(bucket, object, "", etag) |
|
|
|
encodedSuccessResponse := encodeSuccessResponse(response, acceptsContentType) |
|
|
|
encodedSuccessResponse := encodeSuccessResponse(response, acceptsContentType) |
|
|
|
// write headers
|
|
|
|
// write headers
|
|
|
|
setCommonHeaders(w, getContentTypeString(acceptsContentType), len(encodedSuccessResponse)) |
|
|
|
setCommonHeaders(w, getContentTypeString(acceptsContentType), len(encodedSuccessResponse)) |
|
|
|
// write body
|
|
|
|
// write body
|
|
|
|
w.Write(encodedSuccessResponse) |
|
|
|
w.Write(encodedSuccessResponse) |
|
|
|
|
|
|
|
} |
|
|
|
case drivers.InvalidUploadID: |
|
|
|
case drivers.InvalidUploadID: |
|
|
|
|
|
|
|
{ |
|
|
|
writeErrorResponse(w, req, NoSuchUpload, acceptsContentType, req.URL.Path) |
|
|
|
writeErrorResponse(w, req, NoSuchUpload, acceptsContentType, req.URL.Path) |
|
|
|
|
|
|
|
} |
|
|
|
default: |
|
|
|
default: |
|
|
|
|
|
|
|
{ |
|
|
|
log.Println(iodine.New(err, nil)) |
|
|
|
log.Println(iodine.New(err, nil)) |
|
|
|
writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path) |
|
|
|
writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|