|
|
@ -84,6 +84,13 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req |
|
|
|
bucket = vars["bucket"] |
|
|
|
bucket = vars["bucket"] |
|
|
|
object = vars["object"] |
|
|
|
object = vars["object"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Fetch object stat info.
|
|
|
|
|
|
|
|
objectAPI := api.ObjectAPI() |
|
|
|
|
|
|
|
if objectAPI == nil { |
|
|
|
|
|
|
|
writeErrorResponse(w, r, ErrServerNotInitialized, r.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch getRequestAuthType(r) { |
|
|
|
switch getRequestAuthType(r) { |
|
|
|
default: |
|
|
|
default: |
|
|
|
// For all unknown auth types return error.
|
|
|
|
// For all unknown auth types return error.
|
|
|
@ -101,12 +108,6 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// Fetch object stat info.
|
|
|
|
|
|
|
|
objectAPI := api.ObjectAPI() |
|
|
|
|
|
|
|
if objectAPI == nil { |
|
|
|
|
|
|
|
writeErrorResponse(w, r, ErrInternalError, r.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
objInfo, err := objectAPI.GetObjectInfo(bucket, object) |
|
|
|
objInfo, err := objectAPI.GetObjectInfo(bucket, object) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
errorIf(err, "Unable to fetch object info.") |
|
|
|
errorIf(err, "Unable to fetch object info.") |
|
|
@ -195,6 +196,12 @@ func (api objectAPIHandlers) HeadObjectHandler(w http.ResponseWriter, r *http.Re |
|
|
|
bucket = vars["bucket"] |
|
|
|
bucket = vars["bucket"] |
|
|
|
object = vars["object"] |
|
|
|
object = vars["object"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
objectAPI := api.ObjectAPI() |
|
|
|
|
|
|
|
if objectAPI == nil { |
|
|
|
|
|
|
|
writeErrorResponse(w, r, ErrServerNotInitialized, r.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch getRequestAuthType(r) { |
|
|
|
switch getRequestAuthType(r) { |
|
|
|
default: |
|
|
|
default: |
|
|
|
// For all unknown auth types return error.
|
|
|
|
// For all unknown auth types return error.
|
|
|
@ -213,11 +220,6 @@ func (api objectAPIHandlers) HeadObjectHandler(w http.ResponseWriter, r *http.Re |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
objectAPI := api.ObjectAPI() |
|
|
|
|
|
|
|
if objectAPI == nil { |
|
|
|
|
|
|
|
writeErrorResponse(w, r, ErrInternalError, r.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
objInfo, err := objectAPI.GetObjectInfo(bucket, object) |
|
|
|
objInfo, err := objectAPI.GetObjectInfo(bucket, object) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
errorIf(err, "Unable to fetch object info.") |
|
|
|
errorIf(err, "Unable to fetch object info.") |
|
|
@ -250,6 +252,12 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re |
|
|
|
bucket := vars["bucket"] |
|
|
|
bucket := vars["bucket"] |
|
|
|
object := vars["object"] |
|
|
|
object := vars["object"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
objectAPI := api.ObjectAPI() |
|
|
|
|
|
|
|
if objectAPI == nil { |
|
|
|
|
|
|
|
writeErrorResponse(w, r, ErrServerNotInitialized, r.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch getRequestAuthType(r) { |
|
|
|
switch getRequestAuthType(r) { |
|
|
|
default: |
|
|
|
default: |
|
|
|
// For all unknown auth types return error.
|
|
|
|
// For all unknown auth types return error.
|
|
|
@ -299,11 +307,6 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
objectAPI := api.ObjectAPI() |
|
|
|
|
|
|
|
if objectAPI == nil { |
|
|
|
|
|
|
|
writeErrorResponse(w, r, ErrInternalError, r.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
objInfo, err := objectAPI.GetObjectInfo(sourceBucket, sourceObject) |
|
|
|
objInfo, err := objectAPI.GetObjectInfo(sourceBucket, sourceObject) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
errorIf(err, "Unable to fetch object info.") |
|
|
|
errorIf(err, "Unable to fetch object info.") |
|
|
@ -389,6 +392,12 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re |
|
|
|
// ----------
|
|
|
|
// ----------
|
|
|
|
// This implementation of the PUT operation adds an object to a bucket.
|
|
|
|
// This implementation of the PUT operation adds an object to a bucket.
|
|
|
|
func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
|
|
objectAPI := api.ObjectAPI() |
|
|
|
|
|
|
|
if objectAPI == nil { |
|
|
|
|
|
|
|
writeErrorResponse(w, r, ErrServerNotInitialized, r.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// If the matching failed, it means that the X-Amz-Copy-Source was
|
|
|
|
// If the matching failed, it means that the X-Amz-Copy-Source was
|
|
|
|
// wrong, fail right here.
|
|
|
|
// wrong, fail right here.
|
|
|
|
if _, ok := r.Header["X-Amz-Copy-Source"]; ok { |
|
|
|
if _, ok := r.Header["X-Amz-Copy-Source"]; ok { |
|
|
@ -433,11 +442,6 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req |
|
|
|
// Make sure we hex encode md5sum here.
|
|
|
|
// Make sure we hex encode md5sum here.
|
|
|
|
metadata["md5Sum"] = hex.EncodeToString(md5Bytes) |
|
|
|
metadata["md5Sum"] = hex.EncodeToString(md5Bytes) |
|
|
|
|
|
|
|
|
|
|
|
objectAPI := api.ObjectAPI() |
|
|
|
|
|
|
|
if objectAPI == nil { |
|
|
|
|
|
|
|
writeErrorResponse(w, r, ErrInternalError, r.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var md5Sum string |
|
|
|
var md5Sum string |
|
|
|
switch rAuthType { |
|
|
|
switch rAuthType { |
|
|
|
default: |
|
|
|
default: |
|
|
@ -505,6 +509,12 @@ func (api objectAPIHandlers) NewMultipartUploadHandler(w http.ResponseWriter, r |
|
|
|
bucket = vars["bucket"] |
|
|
|
bucket = vars["bucket"] |
|
|
|
object = vars["object"] |
|
|
|
object = vars["object"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
objectAPI := api.ObjectAPI() |
|
|
|
|
|
|
|
if objectAPI == nil { |
|
|
|
|
|
|
|
writeErrorResponse(w, r, ErrServerNotInitialized, r.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch getRequestAuthType(r) { |
|
|
|
switch getRequestAuthType(r) { |
|
|
|
default: |
|
|
|
default: |
|
|
|
// For all unknown auth types return error.
|
|
|
|
// For all unknown auth types return error.
|
|
|
@ -526,11 +536,6 @@ func (api objectAPIHandlers) NewMultipartUploadHandler(w http.ResponseWriter, r |
|
|
|
// Extract metadata that needs to be saved.
|
|
|
|
// Extract metadata that needs to be saved.
|
|
|
|
metadata := extractMetadataFromHeader(r.Header) |
|
|
|
metadata := extractMetadataFromHeader(r.Header) |
|
|
|
|
|
|
|
|
|
|
|
objectAPI := api.ObjectAPI() |
|
|
|
|
|
|
|
if objectAPI == nil { |
|
|
|
|
|
|
|
writeErrorResponse(w, r, ErrInternalError, r.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
uploadID, err := objectAPI.NewMultipartUpload(bucket, object, metadata) |
|
|
|
uploadID, err := objectAPI.NewMultipartUpload(bucket, object, metadata) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
errorIf(err, "Unable to initiate new multipart upload id.") |
|
|
|
errorIf(err, "Unable to initiate new multipart upload id.") |
|
|
@ -552,6 +557,12 @@ func (api objectAPIHandlers) PutObjectPartHandler(w http.ResponseWriter, r *http |
|
|
|
bucket := vars["bucket"] |
|
|
|
bucket := vars["bucket"] |
|
|
|
object := vars["object"] |
|
|
|
object := vars["object"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
objectAPI := api.ObjectAPI() |
|
|
|
|
|
|
|
if objectAPI == nil { |
|
|
|
|
|
|
|
writeErrorResponse(w, r, ErrServerNotInitialized, r.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// get Content-Md5 sent by client and verify if valid
|
|
|
|
// get Content-Md5 sent by client and verify if valid
|
|
|
|
md5Bytes, err := checkValidMD5(r.Header.Get("Content-Md5")) |
|
|
|
md5Bytes, err := checkValidMD5(r.Header.Get("Content-Md5")) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
@ -599,11 +610,6 @@ func (api objectAPIHandlers) PutObjectPartHandler(w http.ResponseWriter, r *http |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
objectAPI := api.ObjectAPI() |
|
|
|
|
|
|
|
if objectAPI == nil { |
|
|
|
|
|
|
|
writeErrorResponse(w, r, ErrInternalError, r.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var partMD5 string |
|
|
|
var partMD5 string |
|
|
|
incomingMD5 := hex.EncodeToString(md5Bytes) |
|
|
|
incomingMD5 := hex.EncodeToString(md5Bytes) |
|
|
|
switch rAuthType { |
|
|
|
switch rAuthType { |
|
|
@ -650,6 +656,12 @@ func (api objectAPIHandlers) AbortMultipartUploadHandler(w http.ResponseWriter, |
|
|
|
bucket := vars["bucket"] |
|
|
|
bucket := vars["bucket"] |
|
|
|
object := vars["object"] |
|
|
|
object := vars["object"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
objectAPI := api.ObjectAPI() |
|
|
|
|
|
|
|
if objectAPI == nil { |
|
|
|
|
|
|
|
writeErrorResponse(w, r, ErrServerNotInitialized, r.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch getRequestAuthType(r) { |
|
|
|
switch getRequestAuthType(r) { |
|
|
|
default: |
|
|
|
default: |
|
|
|
// For all unknown auth types return error.
|
|
|
|
// For all unknown auth types return error.
|
|
|
@ -668,11 +680,6 @@ func (api objectAPIHandlers) AbortMultipartUploadHandler(w http.ResponseWriter, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
objectAPI := api.ObjectAPI() |
|
|
|
|
|
|
|
if objectAPI == nil { |
|
|
|
|
|
|
|
writeErrorResponse(w, r, ErrInternalError, r.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
uploadID, _, _, _ := getObjectResources(r.URL.Query()) |
|
|
|
uploadID, _, _, _ := getObjectResources(r.URL.Query()) |
|
|
|
if err := objectAPI.AbortMultipartUpload(bucket, object, uploadID); err != nil { |
|
|
|
if err := objectAPI.AbortMultipartUpload(bucket, object, uploadID); err != nil { |
|
|
|
errorIf(err, "Unable to abort multipart upload.") |
|
|
|
errorIf(err, "Unable to abort multipart upload.") |
|
|
@ -688,6 +695,12 @@ func (api objectAPIHandlers) ListObjectPartsHandler(w http.ResponseWriter, r *ht |
|
|
|
bucket := vars["bucket"] |
|
|
|
bucket := vars["bucket"] |
|
|
|
object := vars["object"] |
|
|
|
object := vars["object"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
objectAPI := api.ObjectAPI() |
|
|
|
|
|
|
|
if objectAPI == nil { |
|
|
|
|
|
|
|
writeErrorResponse(w, r, ErrServerNotInitialized, r.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch getRequestAuthType(r) { |
|
|
|
switch getRequestAuthType(r) { |
|
|
|
default: |
|
|
|
default: |
|
|
|
// For all unknown auth types return error.
|
|
|
|
// For all unknown auth types return error.
|
|
|
@ -715,11 +728,6 @@ func (api objectAPIHandlers) ListObjectPartsHandler(w http.ResponseWriter, r *ht |
|
|
|
writeErrorResponse(w, r, ErrInvalidMaxParts, r.URL.Path) |
|
|
|
writeErrorResponse(w, r, ErrInvalidMaxParts, r.URL.Path) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
objectAPI := api.ObjectAPI() |
|
|
|
|
|
|
|
if objectAPI == nil { |
|
|
|
|
|
|
|
writeErrorResponse(w, r, ErrInternalError, r.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
listPartsInfo, err := objectAPI.ListObjectParts(bucket, object, uploadID, partNumberMarker, maxParts) |
|
|
|
listPartsInfo, err := objectAPI.ListObjectParts(bucket, object, uploadID, partNumberMarker, maxParts) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
errorIf(err, "Unable to list uploaded parts.") |
|
|
|
errorIf(err, "Unable to list uploaded parts.") |
|
|
@ -740,6 +748,12 @@ func (api objectAPIHandlers) CompleteMultipartUploadHandler(w http.ResponseWrite |
|
|
|
bucket := vars["bucket"] |
|
|
|
bucket := vars["bucket"] |
|
|
|
object := vars["object"] |
|
|
|
object := vars["object"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
objectAPI := api.ObjectAPI() |
|
|
|
|
|
|
|
if objectAPI == nil { |
|
|
|
|
|
|
|
writeErrorResponse(w, r, ErrServerNotInitialized, r.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Get upload id.
|
|
|
|
// Get upload id.
|
|
|
|
uploadID, _, _, _ := getObjectResources(r.URL.Query()) |
|
|
|
uploadID, _, _, _ := getObjectResources(r.URL.Query()) |
|
|
|
|
|
|
|
|
|
|
@ -801,12 +815,8 @@ func (api objectAPIHandlers) CompleteMultipartUploadHandler(w http.ResponseWrite |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
objectAPI := api.ObjectAPI() |
|
|
|
|
|
|
|
if objectAPI == nil { |
|
|
|
|
|
|
|
writeErrorResponse(w, r, ErrInternalError, r.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
doneCh := make(chan struct{}) |
|
|
|
doneCh := make(chan struct{}) |
|
|
|
|
|
|
|
|
|
|
|
// Signal that completeMultipartUpload is over via doneCh
|
|
|
|
// Signal that completeMultipartUpload is over via doneCh
|
|
|
|
go func(doneCh chan<- struct{}) { |
|
|
|
go func(doneCh chan<- struct{}) { |
|
|
|
md5Sum, err = objectAPI.CompleteMultipartUpload(bucket, object, uploadID, completeParts) |
|
|
|
md5Sum, err = objectAPI.CompleteMultipartUpload(bucket, object, uploadID, completeParts) |
|
|
@ -870,6 +880,12 @@ func (api objectAPIHandlers) DeleteObjectHandler(w http.ResponseWriter, r *http. |
|
|
|
bucket := vars["bucket"] |
|
|
|
bucket := vars["bucket"] |
|
|
|
object := vars["object"] |
|
|
|
object := vars["object"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
objectAPI := api.ObjectAPI() |
|
|
|
|
|
|
|
if objectAPI == nil { |
|
|
|
|
|
|
|
writeErrorResponse(w, r, ErrServerNotInitialized, r.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch getRequestAuthType(r) { |
|
|
|
switch getRequestAuthType(r) { |
|
|
|
default: |
|
|
|
default: |
|
|
|
// For all unknown auth types return error.
|
|
|
|
// For all unknown auth types return error.
|
|
|
@ -887,11 +903,6 @@ func (api objectAPIHandlers) DeleteObjectHandler(w http.ResponseWriter, r *http. |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
objectAPI := api.ObjectAPI() |
|
|
|
|
|
|
|
if objectAPI == nil { |
|
|
|
|
|
|
|
writeErrorResponse(w, r, ErrInternalError, r.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectDELETE.html
|
|
|
|
/// http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectDELETE.html
|
|
|
|
/// Ignore delete object errors, since we are suppposed to reply
|
|
|
|
/// Ignore delete object errors, since we are suppposed to reply
|
|
|
|
/// only 204.
|
|
|
|
/// only 204.
|
|
|
|