2023-08-31 08:37:03 +00:00
|
|
|
package handler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
2023-10-04 11:50:37 +00:00
|
|
|
"fmt"
|
2023-08-31 08:37:03 +00:00
|
|
|
"io"
|
|
|
|
"net/url"
|
2023-10-04 11:50:37 +00:00
|
|
|
"strings"
|
2023-08-31 08:37:03 +00:00
|
|
|
|
2023-10-04 11:50:37 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/internal/cache"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/internal/data"
|
2023-11-28 08:29:08 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/internal/handler/middleware"
|
2024-12-02 08:45:30 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/internal/layer"
|
2023-08-31 08:37:03 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/internal/logs"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/response"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/utils"
|
2024-06-17 14:56:43 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/bearer"
|
2023-10-04 11:50:37 +00:00
|
|
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
|
2023-08-31 08:37:03 +00:00
|
|
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
|
|
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user"
|
2024-10-10 08:59:53 +00:00
|
|
|
"github.com/panjf2000/ants/v2"
|
2023-08-31 08:37:03 +00:00
|
|
|
"github.com/valyala/fasthttp"
|
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
2023-09-05 15:17:22 +00:00
|
|
|
type Config interface {
|
|
|
|
DefaultTimestamp() bool
|
|
|
|
ZipCompression() bool
|
2023-08-21 13:50:23 +00:00
|
|
|
ClientCut() bool
|
2024-09-26 14:32:27 +00:00
|
|
|
IndexPageEnabled() bool
|
|
|
|
IndexPageTemplate() string
|
2023-08-25 11:53:59 +00:00
|
|
|
BufferMaxSizeForPut() uint64
|
2023-11-28 08:29:08 +00:00
|
|
|
NamespaceHeader() string
|
2024-12-12 06:28:22 +00:00
|
|
|
EnableFilepathFallback() bool
|
2023-09-05 15:17:22 +00:00
|
|
|
}
|
|
|
|
|
2024-06-17 14:56:43 +00:00
|
|
|
// PrmContainer groups parameters of FrostFS.Container operation.
|
|
|
|
type PrmContainer struct {
|
|
|
|
// Container identifier.
|
|
|
|
ContainerID cid.ID
|
|
|
|
}
|
|
|
|
|
|
|
|
// PrmAuth groups authentication parameters for the FrostFS operation.
|
|
|
|
type PrmAuth struct {
|
|
|
|
// Bearer token to be used for the operation. Overlaps PrivateKey. Optional.
|
|
|
|
BearerToken *bearer.Token
|
|
|
|
}
|
|
|
|
|
2024-07-15 13:35:08 +00:00
|
|
|
// PrmObjectHead groups parameters of FrostFS.HeadObject operation.
|
|
|
|
type PrmObjectHead struct {
|
|
|
|
// Authentication parameters.
|
|
|
|
PrmAuth
|
|
|
|
|
|
|
|
// Address to read the object header from.
|
|
|
|
Address oid.Address
|
|
|
|
}
|
|
|
|
|
|
|
|
// PrmObjectGet groups parameters of FrostFS.GetObject operation.
|
|
|
|
type PrmObjectGet struct {
|
|
|
|
// Authentication parameters.
|
|
|
|
PrmAuth
|
|
|
|
|
|
|
|
// Address to read the object header from.
|
|
|
|
Address oid.Address
|
|
|
|
}
|
|
|
|
|
|
|
|
// PrmObjectRange groups parameters of FrostFS.RangeObject operation.
|
|
|
|
type PrmObjectRange struct {
|
2024-06-17 14:56:43 +00:00
|
|
|
// Authentication parameters.
|
|
|
|
PrmAuth
|
|
|
|
|
|
|
|
// Address to read the object header from.
|
|
|
|
Address oid.Address
|
|
|
|
|
|
|
|
// Offset-length range of the object payload to be read.
|
|
|
|
PayloadRange [2]uint64
|
|
|
|
}
|
|
|
|
|
2024-07-15 13:35:08 +00:00
|
|
|
// Object represents FrostFS object.
|
|
|
|
type Object struct {
|
|
|
|
// Object header (doesn't contain payload).
|
|
|
|
Header object.Object
|
2024-06-17 14:56:43 +00:00
|
|
|
|
|
|
|
// Object payload part encapsulated in io.Reader primitive.
|
|
|
|
// Returns ErrAccessDenied on read access violation.
|
|
|
|
Payload io.ReadCloser
|
|
|
|
}
|
|
|
|
|
|
|
|
// PrmObjectCreate groups parameters of FrostFS.CreateObject operation.
|
|
|
|
type PrmObjectCreate struct {
|
|
|
|
// Authentication parameters.
|
|
|
|
PrmAuth
|
|
|
|
|
|
|
|
Object *object.Object
|
|
|
|
|
|
|
|
// Object payload encapsulated in io.Reader primitive.
|
|
|
|
Payload io.Reader
|
|
|
|
|
|
|
|
// Enables client side object preparing.
|
|
|
|
ClientCut bool
|
|
|
|
|
|
|
|
// Disables using Tillich-Zémor hash for payload.
|
|
|
|
WithoutHomomorphicHash bool
|
|
|
|
|
|
|
|
// Sets max buffer size to read payload.
|
|
|
|
BufferMaxSize uint64
|
|
|
|
}
|
|
|
|
|
|
|
|
// PrmObjectSearch groups parameters of FrostFS.sear SearchObjects operation.
|
|
|
|
type PrmObjectSearch struct {
|
|
|
|
// Authentication parameters.
|
|
|
|
PrmAuth
|
|
|
|
|
|
|
|
// Container to select the objects from.
|
|
|
|
Container cid.ID
|
|
|
|
|
|
|
|
Filters object.SearchFilters
|
|
|
|
}
|
|
|
|
|
2024-09-18 04:35:26 +00:00
|
|
|
type PrmInitMultiObjectReader struct {
|
|
|
|
// payload range
|
|
|
|
Off, Ln uint64
|
|
|
|
|
|
|
|
Addr oid.Address
|
|
|
|
Bearer *bearer.Token
|
|
|
|
}
|
|
|
|
|
2024-06-17 14:56:43 +00:00
|
|
|
type ResObjectSearch interface {
|
|
|
|
Read(buf []oid.ID) (int, error)
|
|
|
|
Iterate(f func(oid.ID) bool) error
|
|
|
|
Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
// ErrAccessDenied is returned from FrostFS in case of access violation.
|
|
|
|
ErrAccessDenied = errors.New("access denied")
|
|
|
|
// ErrGatewayTimeout is returned from FrostFS in case of timeout, deadline exceeded etc.
|
|
|
|
ErrGatewayTimeout = errors.New("gateway timeout")
|
|
|
|
)
|
|
|
|
|
|
|
|
// FrostFS represents virtual connection to FrostFS network.
|
|
|
|
type FrostFS interface {
|
|
|
|
Container(context.Context, PrmContainer) (*container.Container, error)
|
2024-07-15 13:35:08 +00:00
|
|
|
HeadObject(context.Context, PrmObjectHead) (*object.Object, error)
|
|
|
|
GetObject(context.Context, PrmObjectGet) (*Object, error)
|
|
|
|
RangeObject(context.Context, PrmObjectRange) (io.ReadCloser, error)
|
2024-06-17 14:56:43 +00:00
|
|
|
CreateObject(context.Context, PrmObjectCreate) (oid.ID, error)
|
|
|
|
SearchObjects(context.Context, PrmObjectSearch) (ResObjectSearch, error)
|
2024-09-18 04:35:26 +00:00
|
|
|
InitMultiObjectReader(ctx context.Context, p PrmInitMultiObjectReader) (io.Reader, error)
|
|
|
|
|
2024-06-17 14:56:43 +00:00
|
|
|
utils.EpochInfoFetcher
|
|
|
|
}
|
|
|
|
|
|
|
|
type ContainerResolver interface {
|
|
|
|
Resolve(ctx context.Context, name string) (*cid.ID, error)
|
|
|
|
}
|
|
|
|
|
2023-08-31 08:37:03 +00:00
|
|
|
type Handler struct {
|
|
|
|
log *zap.Logger
|
2024-06-17 14:56:43 +00:00
|
|
|
frostfs FrostFS
|
2023-08-31 08:37:03 +00:00
|
|
|
ownerID *user.ID
|
2023-09-05 15:17:22 +00:00
|
|
|
config Config
|
2024-06-17 14:56:43 +00:00
|
|
|
containerResolver ContainerResolver
|
2024-12-02 08:45:30 +00:00
|
|
|
tree layer.TreeService
|
2023-10-04 11:50:37 +00:00
|
|
|
cache *cache.BucketCache
|
2024-10-10 08:59:53 +00:00
|
|
|
workerPool *ants.Pool
|
2023-08-31 08:37:03 +00:00
|
|
|
}
|
|
|
|
|
2024-06-17 14:56:43 +00:00
|
|
|
type AppParams struct {
|
|
|
|
Logger *zap.Logger
|
|
|
|
FrostFS FrostFS
|
|
|
|
Owner *user.ID
|
|
|
|
Resolver ContainerResolver
|
|
|
|
Cache *cache.BucketCache
|
|
|
|
}
|
|
|
|
|
2024-12-02 08:45:30 +00:00
|
|
|
func New(params *AppParams, config Config, tree layer.TreeService, workerPool *ants.Pool) *Handler {
|
2023-08-31 08:37:03 +00:00
|
|
|
return &Handler{
|
|
|
|
log: params.Logger,
|
2024-06-17 14:56:43 +00:00
|
|
|
frostfs: params.FrostFS,
|
2023-08-31 08:37:03 +00:00
|
|
|
ownerID: params.Owner,
|
2023-09-05 15:17:22 +00:00
|
|
|
config: config,
|
2023-08-31 08:37:03 +00:00
|
|
|
containerResolver: params.Resolver,
|
|
|
|
tree: tree,
|
2023-10-04 11:50:37 +00:00
|
|
|
cache: params.Cache,
|
2024-10-10 08:59:53 +00:00
|
|
|
workerPool: workerPool,
|
2023-08-31 08:37:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-10 08:59:53 +00:00
|
|
|
// byNativeAddress is a wrapper for function (e.g. request.headObject, request.receiveFile) that
|
2023-08-31 08:37:03 +00:00
|
|
|
// prepares request and object address to it.
|
2024-12-02 08:45:30 +00:00
|
|
|
func (h *Handler) byNativeAddress(ctx context.Context, req request, cnrID cid.ID, objID oid.ID, handler func(context.Context, request, oid.Address)) {
|
|
|
|
addr := newAddress(cnrID, objID)
|
|
|
|
handler(ctx, req, addr)
|
2023-08-31 08:37:03 +00:00
|
|
|
}
|
|
|
|
|
2024-10-10 08:59:53 +00:00
|
|
|
// byS3Path is a wrapper for function (e.g. request.headObject, request.receiveFile) that
|
|
|
|
// resolves object address from S3-like path <bucket name>/<object key>.
|
2024-12-02 08:45:30 +00:00
|
|
|
func (h *Handler) byS3Path(ctx context.Context, req request, cnrID cid.ID, path string, handler func(context.Context, request, oid.Address)) {
|
|
|
|
c, log := req.RequestCtx, req.log
|
2024-08-26 15:47:33 +00:00
|
|
|
|
2024-12-02 08:45:30 +00:00
|
|
|
foundOID, err := h.tree.GetLatestVersion(ctx, &cnrID, path)
|
2023-08-31 08:37:03 +00:00
|
|
|
if err != nil {
|
2024-09-26 14:32:27 +00:00
|
|
|
logAndSendBucketError(c, log, err)
|
2023-08-31 08:37:03 +00:00
|
|
|
return
|
|
|
|
}
|
2024-12-02 08:45:30 +00:00
|
|
|
if foundOID.IsDeleteMarker {
|
2023-08-31 08:37:03 +00:00
|
|
|
log.Error(logs.ObjectWasDeleted)
|
2024-09-26 14:32:27 +00:00
|
|
|
response.Error(c, "object deleted", fasthttp.StatusNotFound)
|
2023-08-31 08:37:03 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-12-02 08:45:30 +00:00
|
|
|
addr := newAddress(cnrID, foundOID.OID)
|
|
|
|
handler(ctx, h.newRequest(c, log), addr)
|
2023-08-31 08:37:03 +00:00
|
|
|
}
|
|
|
|
|
2024-10-10 08:59:53 +00:00
|
|
|
// byAttribute is a wrapper similar to byNativeAddress.
|
2024-12-02 08:45:30 +00:00
|
|
|
func (h *Handler) byAttribute(c *fasthttp.RequestCtx, handler func(context.Context, request, oid.Address)) {
|
|
|
|
cidParam, _ := c.UserValue("cid").(string)
|
2024-02-29 09:50:56 +00:00
|
|
|
key, _ := c.UserValue("attr_key").(string)
|
|
|
|
val, _ := c.UserValue("attr_val").(string)
|
|
|
|
|
2024-10-08 09:08:39 +00:00
|
|
|
ctx := utils.GetContextFromRequest(c)
|
|
|
|
log := utils.GetReqLogOrDefault(ctx, h.log)
|
|
|
|
|
2024-02-29 09:50:56 +00:00
|
|
|
key, err := url.QueryUnescape(key)
|
|
|
|
if err != nil {
|
2024-12-02 08:45:30 +00:00
|
|
|
log.Error(logs.FailedToUnescapeQuery, zap.String("cid", cidParam), zap.String("attr_key", key), zap.Error(err))
|
2024-02-29 09:50:56 +00:00
|
|
|
response.Error(c, "could not unescape attr_key: "+err.Error(), fasthttp.StatusBadRequest)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
val, err = url.QueryUnescape(val)
|
|
|
|
if err != nil {
|
2024-12-02 08:45:30 +00:00
|
|
|
log.Error(logs.FailedToUnescapeQuery, zap.String("cid", cidParam), zap.String("attr_val", val), zap.Error(err))
|
2024-02-29 09:50:56 +00:00
|
|
|
response.Error(c, "could not unescape attr_val: "+err.Error(), fasthttp.StatusBadRequest)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-12-02 08:45:30 +00:00
|
|
|
log = log.With(zap.String("cid", cidParam), zap.String("attr_key", key), zap.String("attr_val", val))
|
2023-08-31 08:37:03 +00:00
|
|
|
|
2024-12-02 08:45:30 +00:00
|
|
|
bktInfo, err := h.getBucketInfo(ctx, cidParam, log)
|
2023-08-31 08:37:03 +00:00
|
|
|
if err != nil {
|
2023-10-04 12:39:44 +00:00
|
|
|
logAndSendBucketError(c, log, err)
|
2023-08-31 08:37:03 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-12-12 06:28:22 +00:00
|
|
|
objID, err := h.findObjectByAttribute(ctx, log, bktInfo.CID, key, val)
|
2023-08-31 08:37:03 +00:00
|
|
|
if err != nil {
|
2024-12-12 06:28:22 +00:00
|
|
|
if errors.Is(err, io.EOF) {
|
|
|
|
response.Error(c, err.Error(), fasthttp.StatusNotFound)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
response.Error(c, err.Error(), fasthttp.StatusBadRequest)
|
2023-08-31 08:37:03 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-12-02 08:45:30 +00:00
|
|
|
var addr oid.Address
|
|
|
|
addr.SetContainer(bktInfo.CID)
|
|
|
|
addr.SetObject(objID)
|
2024-12-12 06:28:22 +00:00
|
|
|
|
2024-12-02 08:45:30 +00:00
|
|
|
handler(ctx, h.newRequest(c, log), addr)
|
2024-12-12 06:28:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Handler) findObjectByAttribute(ctx context.Context, log *zap.Logger, cnrID cid.ID, attrKey, attrVal string) (oid.ID, error) {
|
|
|
|
res, err := h.search(ctx, cnrID, attrKey, attrVal, object.MatchStringEqual)
|
|
|
|
if err != nil {
|
|
|
|
log.Error(logs.CouldNotSearchForObjects, zap.Error(err))
|
|
|
|
return oid.ID{}, fmt.Errorf("could not search for objects: %w", err)
|
|
|
|
}
|
2023-08-31 08:37:03 +00:00
|
|
|
defer res.Close()
|
|
|
|
|
|
|
|
buf := make([]oid.ID, 1)
|
|
|
|
|
|
|
|
n, err := res.Read(buf)
|
|
|
|
if n == 0 {
|
2024-12-12 06:28:22 +00:00
|
|
|
switch {
|
|
|
|
case errors.Is(err, io.EOF) && h.needSearchByFileName(attrKey, attrVal):
|
|
|
|
log.Debug(logs.ObjectNotFoundByFilePathTrySearchByFileName)
|
|
|
|
return h.findObjectByAttribute(ctx, log, cnrID, attrFileName, attrVal)
|
|
|
|
case errors.Is(err, io.EOF):
|
2023-08-31 08:37:03 +00:00
|
|
|
log.Error(logs.ObjectNotFound, zap.Error(err))
|
2024-12-12 06:28:22 +00:00
|
|
|
return oid.ID{}, fmt.Errorf("object not found: %w", err)
|
|
|
|
default:
|
|
|
|
log.Error(logs.ReadObjectListFailed, zap.Error(err))
|
|
|
|
return oid.ID{}, fmt.Errorf("read object list failed: %w", err)
|
2023-08-31 08:37:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-12-12 06:28:22 +00:00
|
|
|
return buf[0], nil
|
|
|
|
}
|
2023-08-31 08:37:03 +00:00
|
|
|
|
2024-12-12 06:28:22 +00:00
|
|
|
func (h *Handler) needSearchByFileName(key, val string) bool {
|
|
|
|
if key != attrFilePath || !h.config.EnableFilepathFallback() {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
return strings.HasPrefix(val, "/") && strings.Count(val, "/") == 1 || !strings.Contains(val, "/")
|
2023-08-31 08:37:03 +00:00
|
|
|
}
|
2023-10-04 11:50:37 +00:00
|
|
|
|
|
|
|
// resolveContainer decode container id, if it's not a valid container id
|
|
|
|
// then trey to resolve name using provided resolver.
|
|
|
|
func (h *Handler) resolveContainer(ctx context.Context, containerID string) (*cid.ID, error) {
|
|
|
|
cnrID := new(cid.ID)
|
|
|
|
err := cnrID.DecodeString(containerID)
|
|
|
|
if err != nil {
|
|
|
|
cnrID, err = h.containerResolver.Resolve(ctx, containerID)
|
|
|
|
if err != nil && strings.Contains(err.Error(), "not found") {
|
2023-10-04 12:39:44 +00:00
|
|
|
err = fmt.Errorf("%w: %s", new(apistatus.ContainerNotFound), err.Error())
|
2023-10-04 11:50:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return cnrID, err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Handler) getBucketInfo(ctx context.Context, containerName string, log *zap.Logger) (*data.BucketInfo, error) {
|
2023-11-28 08:29:08 +00:00
|
|
|
ns, err := middleware.GetNamespace(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if bktInfo := h.cache.Get(ns, containerName); bktInfo != nil {
|
2023-10-04 11:50:37 +00:00
|
|
|
return bktInfo, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
cnrID, err := h.resolveContainer(ctx, containerName)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
bktInfo, err := h.readContainer(ctx, *cnrID)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err = h.cache.Put(bktInfo); err != nil {
|
|
|
|
log.Warn(logs.CouldntPutBucketIntoCache,
|
|
|
|
zap.String("bucket name", bktInfo.Name),
|
|
|
|
zap.Stringer("bucket cid", bktInfo.CID),
|
|
|
|
zap.Error(err))
|
|
|
|
}
|
|
|
|
|
|
|
|
return bktInfo, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Handler) readContainer(ctx context.Context, cnrID cid.ID) (*data.BucketInfo, error) {
|
2024-06-17 14:56:43 +00:00
|
|
|
prm := PrmContainer{ContainerID: cnrID}
|
|
|
|
res, err := h.frostfs.Container(ctx, prm)
|
2023-10-04 11:50:37 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("get frostfs container '%s': %w", cnrID.String(), err)
|
|
|
|
}
|
|
|
|
|
|
|
|
bktInfo := &data.BucketInfo{
|
|
|
|
CID: cnrID,
|
|
|
|
Name: cnrID.EncodeToString(),
|
|
|
|
}
|
|
|
|
|
2024-06-17 14:56:43 +00:00
|
|
|
if domain := container.ReadDomain(*res); domain.Name() != "" {
|
2023-10-04 11:50:37 +00:00
|
|
|
bktInfo.Name = domain.Name()
|
|
|
|
bktInfo.Zone = domain.Zone()
|
|
|
|
}
|
|
|
|
|
2024-06-17 14:56:43 +00:00
|
|
|
bktInfo.HomomorphicHashDisabled = container.IsHomomorphicHashingDisabled(*res)
|
2023-10-04 11:50:37 +00:00
|
|
|
|
|
|
|
return bktInfo, err
|
|
|
|
}
|
2024-09-26 14:32:27 +00:00
|
|
|
|
2024-12-02 08:45:30 +00:00
|
|
|
func (h *Handler) browseIndex(c *fasthttp.RequestCtx, isNativeList bool) {
|
2024-10-10 08:59:53 +00:00
|
|
|
if !h.config.IndexPageEnabled() {
|
|
|
|
c.SetStatusCode(fasthttp.StatusNotFound)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
cidURLParam := c.UserValue("cid").(string)
|
|
|
|
oidURLParam := c.UserValue("oid").(string)
|
|
|
|
|
|
|
|
ctx := utils.GetContextFromRequest(c)
|
|
|
|
reqLog := utils.GetReqLogOrDefault(ctx, h.log)
|
|
|
|
log := reqLog.With(zap.String("cid", cidURLParam), zap.String("oid", oidURLParam))
|
|
|
|
|
|
|
|
unescapedKey, err := url.QueryUnescape(oidURLParam)
|
2024-09-26 14:32:27 +00:00
|
|
|
if err != nil {
|
2024-10-10 08:59:53 +00:00
|
|
|
logAndSendBucketError(c, log, err)
|
|
|
|
return
|
2024-09-26 14:32:27 +00:00
|
|
|
}
|
|
|
|
|
2024-10-10 08:59:53 +00:00
|
|
|
bktInfo, err := h.getBucketInfo(ctx, cidURLParam, log)
|
|
|
|
if err != nil {
|
|
|
|
logAndSendBucketError(c, log, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
listFunc := h.getDirObjectsS3
|
2024-12-02 08:45:30 +00:00
|
|
|
if isNativeList {
|
|
|
|
// tree probe failed, trying to use native
|
|
|
|
listFunc = h.getDirObjectsNative
|
2024-09-26 14:32:27 +00:00
|
|
|
}
|
|
|
|
|
2024-10-10 08:59:53 +00:00
|
|
|
h.browseObjects(c, browseParams{
|
|
|
|
bucketInfo: bktInfo,
|
|
|
|
prefix: unescapedKey,
|
|
|
|
listObjects: listFunc,
|
|
|
|
isNative: isNativeList,
|
|
|
|
})
|
2024-09-26 14:32:27 +00:00
|
|
|
}
|