|
|
|
@ -39,15 +39,6 @@ func (api CloudStorageAPI) GetObjectHandler(w http.ResponseWriter, req *http.Req |
|
|
|
|
bucket = vars["bucket"] |
|
|
|
|
object = vars["object"] |
|
|
|
|
|
|
|
|
|
if !api.Anonymous { |
|
|
|
|
if isRequestRequiresACLCheck(req) { |
|
|
|
|
if api.Filesystem.IsPrivateBucket(bucket) { |
|
|
|
|
writeErrorResponse(w, req, AccessDenied, req.URL.Path) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
metadata, err := api.Filesystem.GetObjectMetadata(bucket, object) |
|
|
|
|
if err != nil { |
|
|
|
|
errorIf(err.Trace(), "GetObject failed.", nil) |
|
|
|
@ -87,15 +78,6 @@ func (api CloudStorageAPI) HeadObjectHandler(w http.ResponseWriter, req *http.Re |
|
|
|
|
bucket = vars["bucket"] |
|
|
|
|
object = vars["object"] |
|
|
|
|
|
|
|
|
|
if !api.Anonymous { |
|
|
|
|
if isRequestRequiresACLCheck(req) { |
|
|
|
|
if api.Filesystem.IsPrivateBucket(bucket) { |
|
|
|
|
writeErrorResponse(w, req, AccessDenied, req.URL.Path) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
metadata, err := api.Filesystem.GetObjectMetadata(bucket, object) |
|
|
|
|
if err != nil { |
|
|
|
|
switch err.ToGoError().(type) { |
|
|
|
@ -125,15 +107,6 @@ func (api CloudStorageAPI) PutObjectHandler(w http.ResponseWriter, req *http.Req |
|
|
|
|
bucket = vars["bucket"] |
|
|
|
|
object = vars["object"] |
|
|
|
|
|
|
|
|
|
if !api.Anonymous { |
|
|
|
|
if isRequestRequiresACLCheck(req) { |
|
|
|
|
if api.Filesystem.IsPrivateBucket(bucket) || api.Filesystem.IsReadOnlyBucket(bucket) { |
|
|
|
|
writeErrorResponse(w, req, AccessDenied, req.URL.Path) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// get Content-MD5 sent by client and verify if valid
|
|
|
|
|
md5 := req.Header.Get("Content-MD5") |
|
|
|
|
if !isValidMD5(md5) { |
|
|
|
@ -153,7 +126,6 @@ func (api CloudStorageAPI) PutObjectHandler(w http.ResponseWriter, req *http.Req |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var signature *fs.Signature |
|
|
|
|
if !api.Anonymous { |
|
|
|
|
if isRequestSignatureV4(req) { |
|
|
|
|
// Init signature V4 verification
|
|
|
|
|
var err *probe.Error |
|
|
|
@ -175,7 +147,6 @@ func (api CloudStorageAPI) PutObjectHandler(w http.ResponseWriter, req *http.Req |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
metadata, err := api.Filesystem.CreateObject(bucket, object, md5, size, req.Body, signature) |
|
|
|
|
if err != nil { |
|
|
|
@ -219,14 +190,6 @@ func (api CloudStorageAPI) NewMultipartUploadHandler(w http.ResponseWriter, req |
|
|
|
|
bucket = vars["bucket"] |
|
|
|
|
object = vars["object"] |
|
|
|
|
|
|
|
|
|
if !api.Anonymous { |
|
|
|
|
// Unauthorized multipart uploads are not supported
|
|
|
|
|
if isRequestRequiresACLCheck(req) { |
|
|
|
|
writeErrorResponse(w, req, AccessDenied, req.URL.Path) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
uploadID, err := api.Filesystem.NewMultipartUpload(bucket, object) |
|
|
|
|
if err != nil { |
|
|
|
|
errorIf(err.Trace(), "NewMultipartUpload failed.", nil) |
|
|
|
@ -261,13 +224,6 @@ func (api CloudStorageAPI) PutObjectPartHandler(w http.ResponseWriter, req *http |
|
|
|
|
bucket := vars["bucket"] |
|
|
|
|
object := vars["object"] |
|
|
|
|
|
|
|
|
|
if !api.Anonymous { |
|
|
|
|
if isRequestRequiresACLCheck(req) { |
|
|
|
|
writeErrorResponse(w, req, AccessDenied, req.URL.Path) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// get Content-MD5 sent by client and verify if valid
|
|
|
|
|
md5 := req.Header.Get("Content-MD5") |
|
|
|
|
if !isValidMD5(md5) { |
|
|
|
@ -302,7 +258,6 @@ func (api CloudStorageAPI) PutObjectPartHandler(w http.ResponseWriter, req *http |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var signature *fs.Signature |
|
|
|
|
if !api.Anonymous { |
|
|
|
|
if isRequestSignatureV4(req) { |
|
|
|
|
// Init signature V4 verification
|
|
|
|
|
var err *probe.Error |
|
|
|
@ -324,7 +279,6 @@ func (api CloudStorageAPI) PutObjectPartHandler(w http.ResponseWriter, req *http |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
calculatedMD5, err := api.Filesystem.CreateObjectPart(bucket, object, uploadID, md5, partID, size, req.Body, signature) |
|
|
|
|
if err != nil { |
|
|
|
@ -361,13 +315,6 @@ func (api CloudStorageAPI) AbortMultipartUploadHandler(w http.ResponseWriter, re |
|
|
|
|
bucket := vars["bucket"] |
|
|
|
|
object := vars["object"] |
|
|
|
|
|
|
|
|
|
if !api.Anonymous { |
|
|
|
|
if isRequestRequiresACLCheck(req) { |
|
|
|
|
writeErrorResponse(w, req, AccessDenied, req.URL.Path) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
objectResourcesMetadata := getObjectResources(req.URL.Query()) |
|
|
|
|
err := api.Filesystem.AbortMultipartUpload(bucket, object, objectResourcesMetadata.UploadID) |
|
|
|
|
if err != nil { |
|
|
|
@ -397,13 +344,6 @@ func (api CloudStorageAPI) ListObjectPartsHandler(w http.ResponseWriter, req *ht |
|
|
|
|
bucket := vars["bucket"] |
|
|
|
|
object := vars["object"] |
|
|
|
|
|
|
|
|
|
if !api.Anonymous { |
|
|
|
|
if isRequestRequiresACLCheck(req) { |
|
|
|
|
writeErrorResponse(w, req, AccessDenied, req.URL.Path) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
objectResourcesMetadata := getObjectResources(req.URL.Query()) |
|
|
|
|
if objectResourcesMetadata.PartNumberMarker < 0 { |
|
|
|
|
writeErrorResponse(w, req, InvalidPartNumberMarker, req.URL.Path) |
|
|
|
@ -450,16 +390,8 @@ func (api CloudStorageAPI) CompleteMultipartUploadHandler(w http.ResponseWriter, |
|
|
|
|
bucket := vars["bucket"] |
|
|
|
|
object := vars["object"] |
|
|
|
|
|
|
|
|
|
if !api.Anonymous { |
|
|
|
|
if isRequestRequiresACLCheck(req) { |
|
|
|
|
writeErrorResponse(w, req, AccessDenied, req.URL.Path) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
objectResourcesMetadata := getObjectResources(req.URL.Query()) |
|
|
|
|
var signature *fs.Signature |
|
|
|
|
if !api.Anonymous { |
|
|
|
|
if isRequestSignatureV4(req) { |
|
|
|
|
// Init signature V4 verification
|
|
|
|
|
var err *probe.Error |
|
|
|
@ -481,7 +413,6 @@ func (api CloudStorageAPI) CompleteMultipartUploadHandler(w http.ResponseWriter, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
metadata, err := api.Filesystem.CompleteMultipartUpload(bucket, object, objectResourcesMetadata.UploadID, req.Body, signature) |
|
|
|
|
if err != nil { |
|
|
|
@ -528,15 +459,6 @@ func (api CloudStorageAPI) DeleteObjectHandler(w http.ResponseWriter, req *http. |
|
|
|
|
bucket := vars["bucket"] |
|
|
|
|
object := vars["object"] |
|
|
|
|
|
|
|
|
|
if !api.Anonymous { |
|
|
|
|
if isRequestRequiresACLCheck(req) { |
|
|
|
|
if api.Filesystem.IsPrivateBucket(bucket) || api.Filesystem.IsReadOnlyBucket(bucket) { |
|
|
|
|
writeErrorResponse(w, req, AccessDenied, req.URL.Path) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
err := api.Filesystem.DeleteObject(bucket, object) |
|
|
|
|
if err != nil { |
|
|
|
|
errorIf(err.Trace(), "DeleteObject failed.", nil) |
|
|
|
|