2021-04-18 15:41:13 -04:00
|
|
|
// Copyright (c) 2015-2021 MinIO, Inc.
|
|
|
|
//
|
|
|
|
// This file is part of MinIO Object Storage stack
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2016-07-17 15:32:05 -04:00
|
|
|
|
2016-08-18 19:23:42 -04:00
|
|
|
package cmd
|
2016-07-17 15:32:05 -04:00
|
|
|
|
|
|
|
import (
|
2020-07-02 13:56:22 -04:00
|
|
|
"context"
|
2016-07-17 15:32:05 -04:00
|
|
|
"net/http"
|
2020-07-03 14:53:03 -04:00
|
|
|
"strconv"
|
2019-02-24 01:14:24 -05:00
|
|
|
"strings"
|
2016-07-17 15:32:05 -04:00
|
|
|
|
|
|
|
"github.com/gorilla/mux"
|
2022-03-25 18:01:41 -04:00
|
|
|
"github.com/minio/minio/internal/kms"
|
2021-06-01 17:59:40 -04:00
|
|
|
"github.com/minio/minio/internal/logger"
|
2018-08-17 15:52:14 -04:00
|
|
|
|
2021-05-30 00:16:42 -04:00
|
|
|
"github.com/minio/pkg/bucket/policy"
|
2016-07-17 15:32:05 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// Validate all the ListObjects query arguments, returns an APIErrorCode
|
|
|
|
// if one of the args do not meet the required conditions.
|
2019-04-09 14:39:42 -04:00
|
|
|
// Special conditions required by MinIO server are as below
|
2016-07-17 15:32:05 -04:00
|
|
|
// - delimiter if set should be equal to '/', otherwise the request is rejected.
|
|
|
|
// - marker if set should have a common prefix with 'prefix' param, otherwise
|
|
|
|
// the request is rejected.
|
2019-10-15 21:35:41 -04:00
|
|
|
func validateListObjectsArgs(marker, delimiter, encodingType string, maxKeys int) APIErrorCode {
|
2016-07-17 15:32:05 -04:00
|
|
|
// Max keys cannot be negative.
|
|
|
|
if maxKeys < 0 {
|
|
|
|
return ErrInvalidMaxKeys
|
|
|
|
}
|
|
|
|
|
2019-02-24 01:14:24 -05:00
|
|
|
if encodingType != "" {
|
2021-11-16 12:28:29 -05:00
|
|
|
// AWS S3 spec only supports 'url' encoding type
|
|
|
|
if !strings.EqualFold(encodingType, "url") {
|
2019-02-24 01:14:24 -05:00
|
|
|
return ErrInvalidEncodingMethod
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-17 15:32:05 -04:00
|
|
|
return ErrNone
|
|
|
|
}
|
|
|
|
|
2020-06-12 23:04:01 -04:00
|
|
|
// ListObjectVersions - GET Bucket Object versions
|
2019-08-19 17:02:54 -04:00
|
|
|
// You can use the versions subresource to list metadata about all
|
|
|
|
// of the versions of objects in a bucket.
|
2020-06-12 23:04:01 -04:00
|
|
|
func (api objectAPIHandlers) ListObjectVersionsHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "ListObjectVersions")
|
2019-08-19 17:02:54 -04:00
|
|
|
|
2021-01-26 16:21:51 -05:00
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
2019-08-19 17:02:54 -04:00
|
|
|
|
|
|
|
vars := mux.Vars(r)
|
|
|
|
bucket := vars["bucket"]
|
|
|
|
|
|
|
|
objectAPI := api.ObjectAPI()
|
|
|
|
if objectAPI == nil {
|
2021-06-17 23:27:04 -04:00
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrServerNotInitialized), r.URL)
|
2019-08-19 17:02:54 -04:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-09-03 21:25:06 -04:00
|
|
|
if s3Error := checkRequestAuthType(ctx, r, policy.ListBucketVersionsAction, bucket, ""); s3Error != ErrNone {
|
2021-06-17 23:27:04 -04:00
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(s3Error), r.URL)
|
2019-08-19 17:02:54 -04:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-08-08 01:43:01 -04:00
|
|
|
urlValues := r.Form
|
2019-08-19 17:02:54 -04:00
|
|
|
|
|
|
|
// Extract all the listBucketVersions query params to their native values.
|
2020-06-12 23:04:01 -04:00
|
|
|
prefix, marker, delimiter, maxkeys, encodingType, versionIDMarker, errCode := getListBucketObjectVersionsArgs(urlValues)
|
2019-08-19 17:02:54 -04:00
|
|
|
if errCode != ErrNone {
|
2021-06-17 23:27:04 -04:00
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(errCode), r.URL)
|
2019-08-19 17:02:54 -04:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Validate the query params before beginning to serve the request.
|
2019-10-15 21:35:41 -04:00
|
|
|
if s3Error := validateListObjectsArgs(marker, delimiter, encodingType, maxkeys); s3Error != ErrNone {
|
2021-06-17 23:27:04 -04:00
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(s3Error), r.URL)
|
2019-08-19 17:02:54 -04:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-06-12 23:04:01 -04:00
|
|
|
listObjectVersions := objectAPI.ListObjectVersions
|
2019-08-19 17:02:54 -04:00
|
|
|
|
2020-06-12 23:04:01 -04:00
|
|
|
// Inititate a list object versions operation based on the input params.
|
2019-08-19 17:02:54 -04:00
|
|
|
// On success would return back ListObjectsInfo object to be
|
|
|
|
// marshaled into S3 compatible XML header.
|
2020-06-12 23:04:01 -04:00
|
|
|
listObjectVersionsInfo, err := listObjectVersions(ctx, bucket, prefix, marker, versionIDMarker, delimiter, maxkeys)
|
2019-08-19 17:02:54 -04:00
|
|
|
if err != nil {
|
2021-06-17 23:27:04 -04:00
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL)
|
2019-08-19 17:02:54 -04:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-03-25 18:01:41 -04:00
|
|
|
if err = DecryptETags(ctx, GlobalKMS, listObjectVersionsInfo.Objects, kms.BatchSize()); err != nil {
|
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2019-08-19 17:02:54 -04:00
|
|
|
|
2020-06-12 23:04:01 -04:00
|
|
|
response := generateListVersionsResponse(bucket, prefix, marker, versionIDMarker, delimiter, encodingType, maxkeys, listObjectVersionsInfo)
|
2019-08-19 17:02:54 -04:00
|
|
|
|
|
|
|
// Write success response.
|
|
|
|
writeSuccessResponseXML(w, encodeResponse(response))
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:54:49 -05:00
|
|
|
// ListObjectsV2MHandler - GET Bucket (List Objects) Version 2 with metadata.
|
|
|
|
// --------------------------
|
2021-08-31 20:18:13 -04:00
|
|
|
// This implementation of the GET operation returns some or all (up to 1000)
|
2020-10-28 12:18:35 -04:00
|
|
|
// of the objects in a bucket. You can use the request parameters as selection
|
2019-11-21 04:54:49 -05:00
|
|
|
// criteria to return a subset of the objects in a bucket.
|
|
|
|
//
|
|
|
|
// NOTE: It is recommended that this API to be used for application development.
|
|
|
|
// MinIO continues to support ListObjectsV1 and V2 for supporting legacy tools.
|
|
|
|
func (api objectAPIHandlers) ListObjectsV2MHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "ListObjectsV2M")
|
|
|
|
|
2021-01-26 16:21:51 -05:00
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
2019-11-21 04:54:49 -05:00
|
|
|
|
|
|
|
vars := mux.Vars(r)
|
|
|
|
bucket := vars["bucket"]
|
|
|
|
|
|
|
|
objectAPI := api.ObjectAPI()
|
|
|
|
if objectAPI == nil {
|
2021-06-17 23:27:04 -04:00
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrServerNotInitialized), r.URL)
|
2019-11-21 04:54:49 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if s3Error := checkRequestAuthType(ctx, r, policy.ListBucketAction, bucket, ""); s3Error != ErrNone {
|
2021-06-17 23:27:04 -04:00
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(s3Error), r.URL)
|
2019-11-21 04:54:49 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-08-08 01:43:01 -04:00
|
|
|
urlValues := r.Form
|
2019-11-21 04:54:49 -05:00
|
|
|
|
|
|
|
// Extract all the listObjectsV2 query params to their native values.
|
|
|
|
prefix, token, startAfter, delimiter, fetchOwner, maxKeys, encodingType, errCode := getListObjectsV2Args(urlValues)
|
|
|
|
if errCode != ErrNone {
|
2021-06-17 23:27:04 -04:00
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(errCode), r.URL)
|
2019-11-21 04:54:49 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Validate the query params before beginning to serve the request.
|
|
|
|
// fetch-owner is not validated since it is a boolean
|
|
|
|
if s3Error := validateListObjectsArgs(token, delimiter, encodingType, maxKeys); s3Error != ErrNone {
|
2021-06-17 23:27:04 -04:00
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(s3Error), r.URL)
|
2019-11-21 04:54:49 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
listObjectsV2 := objectAPI.ListObjectsV2
|
|
|
|
|
|
|
|
// Inititate a list objects operation based on the input params.
|
|
|
|
// On success would return back ListObjectsInfo object to be
|
|
|
|
// marshaled into S3 compatible XML header.
|
|
|
|
listObjectsV2Info, err := listObjectsV2(ctx, bucket, prefix, token, delimiter, maxKeys, fetchOwner, startAfter)
|
|
|
|
if err != nil {
|
2021-06-17 23:27:04 -04:00
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL)
|
2019-11-21 04:54:49 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-03-25 18:01:41 -04:00
|
|
|
if err = DecryptETags(ctx, GlobalKMS, listObjectsV2Info.Objects, kms.BatchSize()); err != nil {
|
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2019-11-21 04:54:49 -05:00
|
|
|
|
2020-07-03 14:53:03 -04:00
|
|
|
// The next continuation token has id@node_index format to optimize paginated listing
|
2020-07-03 22:27:13 -04:00
|
|
|
nextContinuationToken := listObjectsV2Info.NextContinuationToken
|
2020-07-03 14:53:03 -04:00
|
|
|
|
|
|
|
response := generateListObjectsV2Response(bucket, prefix, token, nextContinuationToken, startAfter,
|
2019-11-21 04:54:49 -05:00
|
|
|
delimiter, encodingType, fetchOwner, listObjectsV2Info.IsTruncated,
|
|
|
|
maxKeys, listObjectsV2Info.Objects, listObjectsV2Info.Prefixes, true)
|
|
|
|
|
|
|
|
// Write success response.
|
|
|
|
writeSuccessResponseXML(w, encodeResponse(response))
|
|
|
|
}
|
|
|
|
|
2016-07-17 15:32:05 -04:00
|
|
|
// ListObjectsV2Handler - GET Bucket (List Objects) Version 2.
|
|
|
|
// --------------------------
|
2021-08-31 20:18:13 -04:00
|
|
|
// This implementation of the GET operation returns some or all (up to 1000)
|
2016-07-17 15:32:05 -04:00
|
|
|
// of the objects in a bucket. You can use the request parameters as selection
|
|
|
|
// criteria to return a subset of the objects in a bucket.
|
|
|
|
//
|
|
|
|
// NOTE: It is recommended that this API to be used for application development.
|
2019-04-09 14:39:42 -04:00
|
|
|
// MinIO continues to support ListObjectsV1 for supporting legacy tools.
|
2016-07-17 15:32:05 -04:00
|
|
|
func (api objectAPIHandlers) ListObjectsV2Handler(w http.ResponseWriter, r *http.Request) {
|
2018-07-20 21:46:32 -04:00
|
|
|
ctx := newContext(r, w, "ListObjectsV2")
|
2018-03-14 15:01:47 -04:00
|
|
|
|
2021-01-26 16:21:51 -05:00
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
2018-10-12 15:25:59 -04:00
|
|
|
|
2016-07-17 15:32:05 -04:00
|
|
|
vars := mux.Vars(r)
|
|
|
|
bucket := vars["bucket"]
|
|
|
|
|
2016-08-10 21:47:49 -04:00
|
|
|
objectAPI := api.ObjectAPI()
|
|
|
|
if objectAPI == nil {
|
2021-06-17 23:27:04 -04:00
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrServerNotInitialized), r.URL)
|
2016-08-10 21:47:49 -04:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-04-24 18:53:30 -04:00
|
|
|
if s3Error := checkRequestAuthType(ctx, r, policy.ListBucketAction, bucket, ""); s3Error != ErrNone {
|
2021-06-17 23:27:04 -04:00
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(s3Error), r.URL)
|
2016-07-17 15:32:05 -04:00
|
|
|
return
|
|
|
|
}
|
2016-11-21 16:51:05 -05:00
|
|
|
|
2021-08-08 01:43:01 -04:00
|
|
|
urlValues := r.Form
|
2018-06-25 15:35:43 -04:00
|
|
|
|
2016-07-17 15:32:05 -04:00
|
|
|
// Extract all the listObjectsV2 query params to their native values.
|
2019-02-24 01:14:24 -05:00
|
|
|
prefix, token, startAfter, delimiter, fetchOwner, maxKeys, encodingType, errCode := getListObjectsV2Args(urlValues)
|
2018-06-25 15:35:43 -04:00
|
|
|
if errCode != ErrNone {
|
2021-06-17 23:27:04 -04:00
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(errCode), r.URL)
|
2018-06-25 15:35:43 -04:00
|
|
|
return
|
|
|
|
}
|
2016-07-17 15:32:05 -04:00
|
|
|
|
2016-09-10 13:44:38 -04:00
|
|
|
// Validate the query params before beginning to serve the request.
|
|
|
|
// fetch-owner is not validated since it is a boolean
|
2019-10-15 21:35:41 -04:00
|
|
|
if s3Error := validateListObjectsArgs(token, delimiter, encodingType, maxKeys); s3Error != ErrNone {
|
2021-06-17 23:27:04 -04:00
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(s3Error), r.URL)
|
2016-07-17 15:32:05 -04:00
|
|
|
return
|
|
|
|
}
|
2019-02-12 04:25:52 -05:00
|
|
|
|
2021-06-10 11:17:03 -04:00
|
|
|
var (
|
|
|
|
listObjectsV2Info ListObjectsV2Info
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
|
|
|
|
if r.Header.Get(xMinIOExtract) == "true" && strings.Contains(prefix, archivePattern) {
|
|
|
|
// Inititate a list objects operation inside a zip file based in the input params
|
|
|
|
listObjectsV2Info, err = listObjectsV2InArchive(ctx, objectAPI, bucket, prefix, token, delimiter, maxKeys, fetchOwner, startAfter)
|
|
|
|
} else {
|
|
|
|
// Inititate a list objects operation based on the input params.
|
|
|
|
// On success would return back ListObjectsInfo object to be
|
|
|
|
// marshaled into S3 compatible XML header.
|
|
|
|
listObjectsV2Info, err = objectAPI.ListObjectsV2(ctx, bucket, prefix, token, delimiter, maxKeys, fetchOwner, startAfter)
|
|
|
|
}
|
2016-07-17 15:32:05 -04:00
|
|
|
if err != nil {
|
2021-06-17 23:27:04 -04:00
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL)
|
2016-07-17 15:32:05 -04:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-03-25 18:01:41 -04:00
|
|
|
if err = DecryptETags(ctx, GlobalKMS, listObjectsV2Info.Objects, kms.BatchSize()); err != nil {
|
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2018-03-01 14:37:57 -05:00
|
|
|
|
2020-10-28 12:18:35 -04:00
|
|
|
response := generateListObjectsV2Response(bucket, prefix, token, listObjectsV2Info.NextContinuationToken, startAfter,
|
2019-11-21 04:54:49 -05:00
|
|
|
delimiter, encodingType, fetchOwner, listObjectsV2Info.IsTruncated,
|
|
|
|
maxKeys, listObjectsV2Info.Objects, listObjectsV2Info.Prefixes, false)
|
2017-01-06 03:37:00 -05:00
|
|
|
|
2016-07-17 15:32:05 -04:00
|
|
|
// Write success response.
|
2017-01-06 03:37:00 -05:00
|
|
|
writeSuccessResponseXML(w, encodeResponse(response))
|
2016-07-17 15:32:05 -04:00
|
|
|
}
|
|
|
|
|
2020-07-03 22:27:13 -04:00
|
|
|
func parseRequestToken(token string) (subToken string, nodeIndex int) {
|
|
|
|
if token == "" {
|
|
|
|
return token, -1
|
|
|
|
}
|
2020-07-03 14:53:03 -04:00
|
|
|
i := strings.Index(token, "@")
|
|
|
|
if i < 0 {
|
2020-07-03 22:27:13 -04:00
|
|
|
return token, -1
|
2020-07-03 14:53:03 -04:00
|
|
|
}
|
|
|
|
nodeIndex, err := strconv.Atoi(token[i+1:])
|
|
|
|
if err != nil {
|
2020-07-03 22:27:13 -04:00
|
|
|
return token, -1
|
2020-07-02 13:56:22 -04:00
|
|
|
}
|
2020-07-03 14:53:03 -04:00
|
|
|
subToken = token[:i]
|
2020-07-03 22:27:13 -04:00
|
|
|
return subToken, nodeIndex
|
|
|
|
}
|
|
|
|
|
|
|
|
func proxyRequestByToken(ctx context.Context, w http.ResponseWriter, r *http.Request, token string) (string, bool) {
|
|
|
|
subToken, nodeIndex := parseRequestToken(token)
|
|
|
|
if nodeIndex > 0 {
|
|
|
|
return subToken, proxyRequestByNodeIndex(ctx, w, r, nodeIndex)
|
|
|
|
}
|
|
|
|
return subToken, false
|
2020-07-03 14:53:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func proxyRequestByNodeIndex(ctx context.Context, w http.ResponseWriter, r *http.Request, index int) (success bool) {
|
|
|
|
if len(globalProxyEndpoints) == 0 {
|
2020-07-02 13:56:22 -04:00
|
|
|
return false
|
|
|
|
}
|
2020-07-03 14:53:03 -04:00
|
|
|
if index < 0 || index >= len(globalProxyEndpoints) {
|
2020-07-02 13:56:22 -04:00
|
|
|
return false
|
|
|
|
}
|
2020-07-03 14:53:03 -04:00
|
|
|
ep := globalProxyEndpoints[index]
|
|
|
|
if ep.IsLocal {
|
|
|
|
return false
|
2020-07-02 13:56:22 -04:00
|
|
|
}
|
2020-07-03 14:53:03 -04:00
|
|
|
return proxyRequest(ctx, w, r, ep)
|
|
|
|
}
|
|
|
|
|
2016-07-17 15:32:05 -04:00
|
|
|
// ListObjectsV1Handler - GET Bucket (List Objects) Version 1.
|
|
|
|
// --------------------------
|
2021-08-31 20:18:13 -04:00
|
|
|
// This implementation of the GET operation returns some or all (up to 1000)
|
2016-07-17 15:32:05 -04:00
|
|
|
// of the objects in a bucket. You can use the request parameters as selection
|
|
|
|
// criteria to return a subset of the objects in a bucket.
|
|
|
|
//
|
|
|
|
func (api objectAPIHandlers) ListObjectsV1Handler(w http.ResponseWriter, r *http.Request) {
|
2018-07-20 21:46:32 -04:00
|
|
|
ctx := newContext(r, w, "ListObjectsV1")
|
2018-03-14 15:01:47 -04:00
|
|
|
|
2021-01-26 16:21:51 -05:00
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
2018-10-12 15:25:59 -04:00
|
|
|
|
2016-07-17 15:32:05 -04:00
|
|
|
vars := mux.Vars(r)
|
|
|
|
bucket := vars["bucket"]
|
|
|
|
|
2016-08-10 21:47:49 -04:00
|
|
|
objectAPI := api.ObjectAPI()
|
|
|
|
if objectAPI == nil {
|
2021-06-17 23:27:04 -04:00
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrServerNotInitialized), r.URL)
|
2016-08-10 21:47:49 -04:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-04-24 18:53:30 -04:00
|
|
|
if s3Error := checkRequestAuthType(ctx, r, policy.ListBucketAction, bucket, ""); s3Error != ErrNone {
|
2021-06-17 23:27:04 -04:00
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(s3Error), r.URL)
|
2016-07-17 15:32:05 -04:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Extract all the litsObjectsV1 query params to their native values.
|
2021-08-08 01:43:01 -04:00
|
|
|
prefix, marker, delimiter, maxKeys, encodingType, s3Error := getListObjectsV1Args(r.Form)
|
2018-10-18 10:31:46 -04:00
|
|
|
if s3Error != ErrNone {
|
2021-06-17 23:27:04 -04:00
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(s3Error), r.URL)
|
2018-10-18 10:31:46 -04:00
|
|
|
return
|
|
|
|
}
|
2016-07-17 15:32:05 -04:00
|
|
|
|
2019-02-12 04:25:52 -05:00
|
|
|
// Validate all the query params before beginning to serve the request.
|
2019-10-15 21:35:41 -04:00
|
|
|
if s3Error := validateListObjectsArgs(marker, delimiter, encodingType, maxKeys); s3Error != ErrNone {
|
2021-06-17 23:27:04 -04:00
|
|
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(s3Error), r.URL)
|
2016-07-17 15:32:05 -04:00
|
|
|
return
|
|
|
|
}
|
2019-02-12 04:25:52 -05:00
|
|
|
|
2018-03-28 17:14:06 -04:00
|
|
|
listObjects := objectAPI.ListObjects
|
2019-02-12 04:25:52 -05:00
|
|
|
|
2016-07-17 15:32:05 -04:00
|
|
|
// Inititate a list objects operation based on the input params.
|
|
|
|
// On success would return back ListObjectsInfo object to be
|
2018-06-28 19:02:02 -04:00
|
|
|
// marshaled into S3 compatible XML header.
|
2018-03-28 17:14:06 -04:00
|
|
|
listObjectsInfo, err := listObjects(ctx, bucket, prefix, marker, delimiter, maxKeys)
|
2016-07-17 15:32:05 -04:00
|
|
|
if err != nil {
|
2021-06-17 23:27:04 -04:00
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL)
|
2016-07-17 15:32:05 -04:00
|
|
|
return
|
|
|
|
}
|
2018-03-01 14:37:57 -05:00
|
|
|
|
2022-03-25 18:01:41 -04:00
|
|
|
if err = DecryptETags(ctx, GlobalKMS, listObjectsInfo.Objects, kms.BatchSize()); err != nil {
|
|
|
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2020-05-24 14:19:17 -04:00
|
|
|
|
2019-02-24 01:14:24 -05:00
|
|
|
response := generateListObjectsV1Response(bucket, prefix, marker, delimiter, encodingType, maxKeys, listObjectsInfo)
|
2017-01-06 03:37:00 -05:00
|
|
|
|
2016-07-17 15:32:05 -04:00
|
|
|
// Write success response.
|
2017-01-06 03:37:00 -05:00
|
|
|
writeSuccessResponseXML(w, encodeResponse(response))
|
2016-07-17 15:32:05 -04:00
|
|
|
}
|