You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
448 lines
14 KiB
448 lines
14 KiB
10 years ago
|
/*
|
||
9 years ago
|
* Minio Cloud Storage, (C) 2015, 2016 Minio, Inc.
|
||
10 years ago
|
*
|
||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
* you may not use this file except in compliance with the License.
|
||
|
* You may obtain a copy of the License at
|
||
|
*
|
||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
*
|
||
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
* See the License for the specific language governing permissions and
|
||
|
* limitations under the License.
|
||
|
*/
|
||
|
|
||
8 years ago
|
package cmd
|
||
10 years ago
|
|
||
|
import (
|
||
9 years ago
|
"encoding/xml"
|
||
9 years ago
|
"io"
|
||
10 years ago
|
"net/http"
|
||
9 years ago
|
"net/url"
|
||
9 years ago
|
"path"
|
||
9 years ago
|
"strings"
|
||
10 years ago
|
|
||
9 years ago
|
mux "github.com/gorilla/mux"
|
||
10 years ago
|
)
|
||
|
|
||
9 years ago
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html
|
||
8 years ago
|
// Enforces bucket policies for a bucket for a given tatusaction.
|
||
|
func enforceBucketPolicy(bucket string, action string, reqURL *url.URL) (s3Error APIErrorCode) {
|
||
|
if !IsValidBucketName(bucket) {
|
||
|
return ErrInvalidBucketName
|
||
|
}
|
||
|
// Fetch bucket policy, if policy is not set return access denied.
|
||
|
policy := globalBucketPolicies.GetBucketPolicy(bucket)
|
||
|
if policy == nil {
|
||
9 years ago
|
return ErrAccessDenied
|
||
9 years ago
|
}
|
||
|
|
||
9 years ago
|
// Construct resource in 'arn:aws:s3:::examplebucket/object' format.
|
||
9 years ago
|
resource := AWSResourcePrefix + strings.TrimPrefix(reqURL.Path, "/")
|
||
9 years ago
|
|
||
|
// Get conditions for policy verification.
|
||
|
conditions := make(map[string]string)
|
||
|
for queryParam := range reqURL.Query() {
|
||
9 years ago
|
conditions[queryParam] = reqURL.Query().Get(queryParam)
|
||
9 years ago
|
}
|
||
|
|
||
|
// Validate action, resource and conditions with current policy statements.
|
||
8 years ago
|
if !bucketPolicyEvalStatements(action, resource, conditions, policy.Statements) {
|
||
9 years ago
|
return ErrAccessDenied
|
||
9 years ago
|
}
|
||
9 years ago
|
return ErrNone
|
||
9 years ago
|
}
|
||
|
|
||
9 years ago
|
// GetBucketLocationHandler - GET Bucket location.
|
||
|
// -------------------------
|
||
|
// This operation returns bucket location.
|
||
9 years ago
|
func (api objectAPIHandlers) GetBucketLocationHandler(w http.ResponseWriter, r *http.Request) {
|
||
9 years ago
|
vars := mux.Vars(r)
|
||
9 years ago
|
bucket := vars["bucket"]
|
||
|
|
||
9 years ago
|
switch getRequestAuthType(r) {
|
||
|
default:
|
||
|
// For all unknown auth types return error.
|
||
9 years ago
|
writeErrorResponse(w, r, ErrAccessDenied, r.URL.Path)
|
||
9 years ago
|
return
|
||
9 years ago
|
case authTypeAnonymous:
|
||
9 years ago
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html
|
||
8 years ago
|
if s3Error := enforceBucketPolicy(bucket, "s3:GetBucketLocation", r.URL); s3Error != ErrNone {
|
||
9 years ago
|
writeErrorResponse(w, r, s3Error, r.URL.Path)
|
||
|
return
|
||
|
}
|
||
|
case authTypeSigned, authTypePresigned:
|
||
9 years ago
|
if s3Error := isReqAuthenticated(r); s3Error != ErrNone {
|
||
9 years ago
|
writeErrorResponse(w, r, s3Error, r.URL.Path)
|
||
|
return
|
||
|
}
|
||
9 years ago
|
}
|
||
|
|
||
9 years ago
|
if _, err := api.ObjectAPI.GetBucketInfo(bucket); err != nil {
|
||
9 years ago
|
errorIf(err, "Unable to fetch bucket info.")
|
||
9 years ago
|
writeErrorResponse(w, r, toAPIErrorCode(err), r.URL.Path)
|
||
9 years ago
|
return
|
||
9 years ago
|
}
|
||
|
|
||
9 years ago
|
// Generate response.
|
||
9 years ago
|
encodedSuccessResponse := encodeResponse(LocationResponse{})
|
||
9 years ago
|
// Get current region.
|
||
|
region := serverConfig.GetRegion()
|
||
|
if region != "us-east-1" {
|
||
9 years ago
|
encodedSuccessResponse = encodeResponse(LocationResponse{
|
||
9 years ago
|
Location: region,
|
||
9 years ago
|
})
|
||
|
}
|
||
9 years ago
|
setCommonHeaders(w) // Write headers.
|
||
9 years ago
|
writeSuccessResponse(w, encodedSuccessResponse)
|
||
9 years ago
|
}
|
||
|
|
||
10 years ago
|
// ListMultipartUploadsHandler - GET Bucket (List Multipart uploads)
|
||
10 years ago
|
// -------------------------
|
||
|
// This operation lists in-progress multipart uploads. An in-progress
|
||
|
// multipart upload is a multipart upload that has been initiated,
|
||
9 years ago
|
// using the Initiate Multipart Upload request, but has not yet been
|
||
|
// completed or aborted. This operation returns at most 1,000 multipart
|
||
|
// uploads in the response.
|
||
10 years ago
|
//
|
||
9 years ago
|
func (api objectAPIHandlers) ListMultipartUploadsHandler(w http.ResponseWriter, r *http.Request) {
|
||
9 years ago
|
vars := mux.Vars(r)
|
||
9 years ago
|
bucket := vars["bucket"]
|
||
|
|
||
9 years ago
|
switch getRequestAuthType(r) {
|
||
|
default:
|
||
|
// For all unknown auth types return error.
|
||
9 years ago
|
writeErrorResponse(w, r, ErrAccessDenied, r.URL.Path)
|
||
9 years ago
|
return
|
||
9 years ago
|
case authTypeAnonymous:
|
||
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/mpuAndPermissions.html
|
||
8 years ago
|
if s3Error := enforceBucketPolicy(bucket, "s3:ListBucketMultipartUploads", r.URL); s3Error != ErrNone {
|
||
9 years ago
|
writeErrorResponse(w, r, s3Error, r.URL.Path)
|
||
|
return
|
||
|
}
|
||
|
case authTypePresigned, authTypeSigned:
|
||
9 years ago
|
if s3Error := isReqAuthenticated(r); s3Error != ErrNone {
|
||
9 years ago
|
writeErrorResponse(w, r, s3Error, r.URL.Path)
|
||
|
return
|
||
|
}
|
||
9 years ago
|
}
|
||
|
|
||
9 years ago
|
prefix, keyMarker, uploadIDMarker, delimiter, maxUploads, _ := getBucketMultipartResources(r.URL.Query())
|
||
|
if maxUploads < 0 {
|
||
9 years ago
|
writeErrorResponse(w, r, ErrInvalidMaxUploads, r.URL.Path)
|
||
10 years ago
|
return
|
||
|
}
|
||
9 years ago
|
if keyMarker != "" {
|
||
9 years ago
|
// Marker not common with prefix is not implemented.
|
||
|
if !strings.HasPrefix(keyMarker, prefix) {
|
||
|
writeErrorResponse(w, r, ErrNotImplemented, r.URL.Path)
|
||
|
return
|
||
9 years ago
|
}
|
||
10 years ago
|
}
|
||
|
|
||
9 years ago
|
listMultipartsInfo, err := api.ObjectAPI.ListMultipartUploads(bucket, prefix, keyMarker, uploadIDMarker, delimiter, maxUploads)
|
||
9 years ago
|
if err != nil {
|
||
9 years ago
|
errorIf(err, "Unable to list multipart uploads.")
|
||
9 years ago
|
writeErrorResponse(w, r, toAPIErrorCode(err), r.URL.Path)
|
||
10 years ago
|
return
|
||
|
}
|
||
9 years ago
|
// generate response
|
||
9 years ago
|
response := generateListMultipartUploadsResponse(bucket, listMultipartsInfo)
|
||
9 years ago
|
encodedSuccessResponse := encodeResponse(response)
|
||
9 years ago
|
// write headers.
|
||
|
setCommonHeaders(w)
|
||
|
// write success response.
|
||
|
writeSuccessResponse(w, encodedSuccessResponse)
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
// ListBucketsHandler - GET Service
|
||
10 years ago
|
// -----------
|
||
|
// This implementation of the GET operation returns a list of all buckets
|
||
|
// owned by the authenticated sender of the request.
|
||
9 years ago
|
func (api objectAPIHandlers) ListBucketsHandler(w http.ResponseWriter, r *http.Request) {
|
||
9 years ago
|
// List buckets does not support bucket policies, no need to enforce it.
|
||
9 years ago
|
if s3Error := checkAuth(r); s3Error != ErrNone {
|
||
9 years ago
|
writeErrorResponse(w, r, s3Error, r.URL.Path)
|
||
9 years ago
|
return
|
||
9 years ago
|
}
|
||
|
|
||
9 years ago
|
bucketsInfo, err := api.ObjectAPI.ListBuckets()
|
||
9 years ago
|
if err != nil {
|
||
|
errorIf(err, "Unable to list buckets.")
|
||
|
writeErrorResponse(w, r, toAPIErrorCode(err), r.URL.Path)
|
||
10 years ago
|
return
|
||
|
}
|
||
9 years ago
|
|
||
|
// Generate response.
|
||
|
response := generateListBucketsResponse(bucketsInfo)
|
||
|
encodedSuccessResponse := encodeResponse(response)
|
||
|
// Write headers.
|
||
|
setCommonHeaders(w)
|
||
|
// Write response.
|
||
|
writeSuccessResponse(w, encodedSuccessResponse)
|
||
10 years ago
|
}
|
||
|
|
||
9 years ago
|
// DeleteMultipleObjectsHandler - deletes multiple objects.
|
||
9 years ago
|
func (api objectAPIHandlers) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *http.Request) {
|
||
9 years ago
|
vars := mux.Vars(r)
|
||
|
bucket := vars["bucket"]
|
||
|
|
||
9 years ago
|
switch getRequestAuthType(r) {
|
||
|
default:
|
||
|
// For all unknown auth types return error.
|
||
|
writeErrorResponse(w, r, ErrAccessDenied, r.URL.Path)
|
||
|
return
|
||
|
case authTypeAnonymous:
|
||
9 years ago
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html
|
||
8 years ago
|
if s3Error := enforceBucketPolicy(bucket, "s3:DeleteObject", r.URL); s3Error != ErrNone {
|
||
9 years ago
|
writeErrorResponse(w, r, s3Error, r.URL.Path)
|
||
|
return
|
||
|
}
|
||
|
case authTypePresigned, authTypeSigned:
|
||
|
if s3Error := isReqAuthenticated(r); s3Error != ErrNone {
|
||
|
writeErrorResponse(w, r, s3Error, r.URL.Path)
|
||
|
return
|
||
|
}
|
||
|
}
|
||
|
|
||
9 years ago
|
// Content-Length is required and should be non-zero
|
||
|
// http://docs.aws.amazon.com/AmazonS3/latest/API/multiobjectdeleteapi.html
|
||
|
if r.ContentLength <= 0 {
|
||
9 years ago
|
writeErrorResponse(w, r, ErrMissingContentLength, r.URL.Path)
|
||
9 years ago
|
return
|
||
|
}
|
||
|
|
||
|
// Content-Md5 is requied should be set
|
||
|
// http://docs.aws.amazon.com/AmazonS3/latest/API/multiobjectdeleteapi.html
|
||
|
if _, ok := r.Header["Content-Md5"]; !ok {
|
||
9 years ago
|
writeErrorResponse(w, r, ErrMissingContentMD5, r.URL.Path)
|
||
9 years ago
|
return
|
||
|
}
|
||
|
|
||
|
// Allocate incoming content length bytes.
|
||
|
deleteXMLBytes := make([]byte, r.ContentLength)
|
||
|
|
||
|
// Read incoming body XML bytes.
|
||
9 years ago
|
if _, err := io.ReadFull(r.Body, deleteXMLBytes); err != nil {
|
||
9 years ago
|
errorIf(err, "Unable to read HTTP body.")
|
||
9 years ago
|
writeErrorResponse(w, r, ErrInternalError, r.URL.Path)
|
||
9 years ago
|
return
|
||
|
}
|
||
|
|
||
|
// Unmarshal list of keys to be deleted.
|
||
|
deleteObjects := &DeleteObjectsRequest{}
|
||
9 years ago
|
if err := xml.Unmarshal(deleteXMLBytes, deleteObjects); err != nil {
|
||
9 years ago
|
errorIf(err, "Unable to unmarshal delete objects request XML.")
|
||
9 years ago
|
writeErrorResponse(w, r, ErrMalformedXML, r.URL.Path)
|
||
9 years ago
|
return
|
||
|
}
|
||
|
|
||
|
var deleteErrors []DeleteError
|
||
|
var deletedObjects []ObjectIdentifier
|
||
|
// Loop through all the objects and delete them sequentially.
|
||
|
for _, object := range deleteObjects.Objects {
|
||
9 years ago
|
err := api.ObjectAPI.DeleteObject(bucket, object.ObjectName)
|
||
9 years ago
|
if err == nil {
|
||
|
deletedObjects = append(deletedObjects, ObjectIdentifier{
|
||
|
ObjectName: object.ObjectName,
|
||
|
})
|
||
|
} else {
|
||
9 years ago
|
errorIf(err, "Unable to delete object.")
|
||
9 years ago
|
deleteErrors = append(deleteErrors, DeleteError{
|
||
|
Code: errorCodeResponse[toAPIErrorCode(err)].Code,
|
||
|
Message: errorCodeResponse[toAPIErrorCode(err)].Description,
|
||
|
Key: object.ObjectName,
|
||
|
})
|
||
9 years ago
|
}
|
||
|
}
|
||
|
// Generate response
|
||
|
response := generateMultiDeleteResponse(deleteObjects.Quiet, deletedObjects, deleteErrors)
|
||
|
encodedSuccessResponse := encodeResponse(response)
|
||
|
// Write headers
|
||
|
setCommonHeaders(w)
|
||
|
// Write success response.
|
||
|
writeSuccessResponse(w, encodedSuccessResponse)
|
||
|
}
|
||
|
|
||
10 years ago
|
// PutBucketHandler - PUT Bucket
|
||
10 years ago
|
// ----------
|
||
|
// This implementation of the PUT operation creates a new bucket for authenticated request
|
||
9 years ago
|
func (api objectAPIHandlers) PutBucketHandler(w http.ResponseWriter, r *http.Request) {
|
||
9 years ago
|
// PutBucket does not support policies, use checkAuth to validate signature.
|
||
|
if s3Error := checkAuth(r); s3Error != ErrNone {
|
||
|
writeErrorResponse(w, r, s3Error, r.URL.Path)
|
||
9 years ago
|
return
|
||
10 years ago
|
}
|
||
|
|
||
9 years ago
|
vars := mux.Vars(r)
|
||
|
bucket := vars["bucket"]
|
||
|
|
||
9 years ago
|
// Validate if incoming location constraint is valid, reject
|
||
|
// requests which do not follow valid region requirements.
|
||
9 years ago
|
if s3Error := isValidLocationConstraint(r); s3Error != ErrNone {
|
||
|
writeErrorResponse(w, r, s3Error, r.URL.Path)
|
||
9 years ago
|
}
|
||
9 years ago
|
|
||
|
// Proceed to creating a bucket.
|
||
9 years ago
|
err := api.ObjectAPI.MakeBucket(bucket)
|
||
9 years ago
|
if err != nil {
|
||
9 years ago
|
errorIf(err, "Unable to create a bucket.")
|
||
9 years ago
|
writeErrorResponse(w, r, toAPIErrorCode(err), r.URL.Path)
|
||
10 years ago
|
return
|
||
|
}
|
||
9 years ago
|
// Make sure to add Location information here only for bucket
|
||
9 years ago
|
w.Header().Set("Location", getLocation(r))
|
||
9 years ago
|
writeSuccessResponse(w, nil)
|
||
10 years ago
|
}
|
||
|
|
||
9 years ago
|
// PostPolicyBucketHandler - POST policy
|
||
|
// ----------
|
||
|
// This implementation of the POST operation handles object creation with a specified
|
||
|
// signature policy in multipart/form-data
|
||
9 years ago
|
func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *http.Request) {
|
||
9 years ago
|
// Here the parameter is the size of the form data that should
|
||
9 years ago
|
// be loaded in memory, the remaining being put in temporary files.
|
||
9 years ago
|
reader, err := r.MultipartReader()
|
||
|
if err != nil {
|
||
9 years ago
|
errorIf(err, "Unable to initialize multipart reader.")
|
||
9 years ago
|
writeErrorResponse(w, r, ErrMalformedPOSTRequest, r.URL.Path)
|
||
9 years ago
|
return
|
||
|
}
|
||
|
|
||
9 years ago
|
fileBody, fileName, formValues, err := extractPostPolicyFormValues(reader)
|
||
9 years ago
|
if err != nil {
|
||
9 years ago
|
errorIf(err, "Unable to parse form values.")
|
||
9 years ago
|
writeErrorResponse(w, r, ErrMalformedPOSTRequest, r.URL.Path)
|
||
9 years ago
|
return
|
||
|
}
|
||
9 years ago
|
bucket := mux.Vars(r)["bucket"]
|
||
9 years ago
|
formValues["Bucket"] = bucket
|
||
9 years ago
|
object := formValues["Key"]
|
||
9 years ago
|
|
||
9 years ago
|
if fileName != "" && strings.Contains(object, "${filename}") {
|
||
|
// S3 feature to replace ${filename} found in Key form field
|
||
|
// by the filename attribute passed in multipart
|
||
|
object = strings.Replace(object, "${filename}", fileName, -1)
|
||
|
}
|
||
|
|
||
9 years ago
|
// Verify policy signature.
|
||
9 years ago
|
apiErr := doesPolicySignatureMatch(formValues)
|
||
|
if apiErr != ErrNone {
|
||
|
writeErrorResponse(w, r, apiErr, r.URL.Path)
|
||
9 years ago
|
return
|
||
|
}
|
||
9 years ago
|
if apiErr = checkPostPolicy(formValues); apiErr != ErrNone {
|
||
|
writeErrorResponse(w, r, apiErr, r.URL.Path)
|
||
9 years ago
|
return
|
||
|
}
|
||
9 years ago
|
|
||
|
// Save metadata.
|
||
|
metadata := make(map[string]string)
|
||
|
// Nothing to store right now.
|
||
|
|
||
|
md5Sum, err := api.ObjectAPI.PutObject(bucket, object, -1, fileBody, metadata)
|
||
9 years ago
|
if err != nil {
|
||
9 years ago
|
errorIf(err, "Unable to create object.")
|
||
9 years ago
|
writeErrorResponse(w, r, toAPIErrorCode(err), r.URL.Path)
|
||
9 years ago
|
return
|
||
|
}
|
||
9 years ago
|
if md5Sum != "" {
|
||
|
w.Header().Set("ETag", "\""+md5Sum+"\"")
|
||
9 years ago
|
}
|
||
9 years ago
|
encodedSuccessResponse := encodeResponse(PostResponse{
|
||
|
Location: getObjectLocation(bucket, object), // TODO Full URL is preferred
|
||
9 years ago
|
Bucket: bucket,
|
||
|
Key: object,
|
||
|
ETag: md5Sum,
|
||
9 years ago
|
})
|
||
9 years ago
|
|
||
9 years ago
|
setCommonHeaders(w)
|
||
9 years ago
|
|
||
9 years ago
|
writeSuccessResponse(w, encodedSuccessResponse)
|
||
9 years ago
|
|
||
9 years ago
|
// Fetch object info for notifications.
|
||
|
objInfo, err := api.ObjectAPI.GetObjectInfo(bucket, object)
|
||
|
if err != nil {
|
||
|
errorIf(err, "Unable to fetch object info for \"%s\"", path.Join(bucket, object))
|
||
|
return
|
||
|
}
|
||
|
|
||
9 years ago
|
if eventN.IsBucketNotificationSet(bucket) {
|
||
|
// Notify object created event.
|
||
|
eventNotify(eventData{
|
||
|
Type: ObjectCreatedPost,
|
||
|
Bucket: bucket,
|
||
|
ObjInfo: objInfo,
|
||
|
ReqParams: map[string]string{
|
||
|
"sourceIPAddress": r.RemoteAddr,
|
||
|
},
|
||
|
})
|
||
|
}
|
||
9 years ago
|
}
|
||
|
|
||
10 years ago
|
// HeadBucketHandler - HEAD Bucket
|
||
10 years ago
|
// ----------
|
||
|
// This operation is useful to determine if a bucket exists.
|
||
|
// The operation returns a 200 OK if the bucket exists and you
|
||
|
// have permission to access it. Otherwise, the operation might
|
||
|
// return responses such as 404 Not Found and 403 Forbidden.
|
||
9 years ago
|
func (api objectAPIHandlers) HeadBucketHandler(w http.ResponseWriter, r *http.Request) {
|
||
9 years ago
|
vars := mux.Vars(r)
|
||
10 years ago
|
bucket := vars["bucket"]
|
||
10 years ago
|
|
||
9 years ago
|
switch getRequestAuthType(r) {
|
||
|
default:
|
||
|
// For all unknown auth types return error.
|
||
9 years ago
|
writeErrorResponse(w, r, ErrAccessDenied, r.URL.Path)
|
||
9 years ago
|
return
|
||
9 years ago
|
case authTypeAnonymous:
|
||
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html
|
||
8 years ago
|
if s3Error := enforceBucketPolicy(bucket, "s3:ListBucket", r.URL); s3Error != ErrNone {
|
||
9 years ago
|
writeErrorResponse(w, r, s3Error, r.URL.Path)
|
||
|
return
|
||
|
}
|
||
9 years ago
|
case authTypePresigned, authTypeSigned:
|
||
9 years ago
|
if s3Error := isReqAuthenticated(r); s3Error != ErrNone {
|
||
9 years ago
|
writeErrorResponse(w, r, s3Error, r.URL.Path)
|
||
9 years ago
|
return
|
||
|
}
|
||
|
}
|
||
|
|
||
9 years ago
|
if _, err := api.ObjectAPI.GetBucketInfo(bucket); err != nil {
|
||
9 years ago
|
errorIf(err, "Unable to fetch bucket info.")
|
||
9 years ago
|
writeErrorResponse(w, r, toAPIErrorCode(err), r.URL.Path)
|
||
10 years ago
|
return
|
||
|
}
|
||
9 years ago
|
writeSuccessResponse(w, nil)
|
||
10 years ago
|
}
|
||
9 years ago
|
|
||
|
// DeleteBucketHandler - Delete bucket
|
||
9 years ago
|
func (api objectAPIHandlers) DeleteBucketHandler(w http.ResponseWriter, r *http.Request) {
|
||
9 years ago
|
// DeleteBucket does not support bucket policies, use checkAuth to validate signature.
|
||
|
if s3Error := checkAuth(r); s3Error != ErrNone {
|
||
|
writeErrorResponse(w, r, s3Error, r.URL.Path)
|
||
9 years ago
|
return
|
||
9 years ago
|
}
|
||
|
|
||
9 years ago
|
vars := mux.Vars(r)
|
||
|
bucket := vars["bucket"]
|
||
|
|
||
9 years ago
|
// Attempt to delete bucket.
|
||
9 years ago
|
if err := api.ObjectAPI.DeleteBucket(bucket); err != nil {
|
||
9 years ago
|
errorIf(err, "Unable to delete a bucket.")
|
||
9 years ago
|
writeErrorResponse(w, r, toAPIErrorCode(err), r.URL.Path)
|
||
9 years ago
|
return
|
||
|
}
|
||
9 years ago
|
|
||
|
// Delete bucket access policy, if present - ignore any errors.
|
||
8 years ago
|
removeBucketPolicy(bucket, api.ObjectAPI)
|
||
|
|
||
|
// Delete notification config, if present - ignore any errors.
|
||
|
removeNotificationConfig(bucket, api.ObjectAPI)
|
||
9 years ago
|
|
||
|
// Write success response.
|
||
9 years ago
|
writeSuccessNoContent(w)
|
||
9 years ago
|
}
|