mirror of
https://github.com/versity/versitygw.git
synced 2026-01-06 11:46:20 +00:00
4
go.mod
4
go.mod
@@ -20,12 +20,12 @@ require (
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.2 // indirect
|
||||
github.com/aws/smithy-go v1.13.5 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/klauspost/compress v1.16.3 // indirect
|
||||
github.com/klauspost/compress v1.16.5 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.18 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.14 // indirect
|
||||
github.com/philhofer/fwd v1.1.2 // indirect
|
||||
github.com/rivo/uniseg v0.2.0 // indirect
|
||||
github.com/rivo/uniseg v0.4.4 // indirect
|
||||
github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94 // indirect
|
||||
github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee // indirect
|
||||
github.com/tinylib/msgp v1.1.8 // indirect
|
||||
|
||||
7
go.sum
7
go.sum
@@ -31,8 +31,8 @@ github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
||||
github.com/klauspost/compress v1.16.3 h1:XuJt9zzcnaz6a16/OU53ZjWp/v7/42WcR5t2a0PcNQY=
|
||||
github.com/klauspost/compress v1.16.3/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
|
||||
github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI=
|
||||
github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
@@ -44,8 +44,9 @@ github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG
|
||||
github.com/philhofer/fwd v1.1.2 h1:bnDivRJ1EWPjUIRXV5KfORO897HTbpFAQddBdE8t7Gw=
|
||||
github.com/philhofer/fwd v1.1.2/go.mod h1:qkPdfjR2SIEbspLqpe1tO4n5yICnr2DY7mqEx2tUTP0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
|
||||
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94 h1:rmMl4fXJhKMNWl+K+r/fq4FbbKI+Ia2m9hYBLm2h4G4=
|
||||
github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94/go.mod h1:90zrgN3D/WJsDd1iXHT96alCoN2KJo6/4x1DZC3wZs8=
|
||||
github.com/savsgio/gotils v0.0.0-20220530130905-52f3993e8d6d/go.mod h1:Gy+0tqhJvgGlqnTF8CVGP0AaGRjwBtXs/a5PA0Y3+A4=
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
package internal
|
||||
|
||||
type Any any
|
||||
@@ -1,9 +0,0 @@
|
||||
package s3api
|
||||
|
||||
const (
|
||||
ACTION_READ = "Read"
|
||||
ACTION_WRITE = "Write"
|
||||
ACTION_ADMIN = "Admin"
|
||||
ACTION_TAGGING = "Tagging"
|
||||
ACTION_LIST = "List"
|
||||
)
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
"github.com/aws/aws-sdk-go-v2/service/s3/types"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/versity/scoutgw/backend"
|
||||
"github.com/versity/scoutgw/internal"
|
||||
"github.com/versity/scoutgw/s3err"
|
||||
)
|
||||
|
||||
@@ -28,7 +27,7 @@ func New(be backend.Backend) S3ApiController {
|
||||
|
||||
func (c S3ApiController) ListBuckets(ctx *fiber.Ctx) error {
|
||||
res, code := c.be.ListBuckets()
|
||||
return responce[*s3.ListBucketsOutput](ctx, res, code)
|
||||
return responce(ctx, res, code)
|
||||
}
|
||||
|
||||
func (c S3ApiController) GetActions(ctx *fiber.Ctx) error {
|
||||
@@ -49,17 +48,17 @@ func (c S3ApiController) GetActions(ctx *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
res, code := c.be.ListObjectParts(bucket, "", uploadId, partNumberMarker, maxParts)
|
||||
return responce[*s3.ListPartsOutput](ctx, res, code)
|
||||
return responce(ctx, res, code)
|
||||
}
|
||||
|
||||
if ctx.Request().URI().QueryArgs().Has("acl") {
|
||||
res, code := c.be.GetObjectAcl(bucket, key)
|
||||
return responce[*s3.GetObjectAclOutput](ctx, res, code)
|
||||
return responce(ctx, res, code)
|
||||
}
|
||||
|
||||
if attrs := ctx.Get("X-Amz-Object-Attributes"); attrs != "" {
|
||||
res, code := c.be.GetObjectAttributes(bucket, key, strings.Split(attrs, ","))
|
||||
return responce[*s3.GetObjectAttributesOutput](ctx, res, code)
|
||||
return responce(ctx, res, code)
|
||||
}
|
||||
|
||||
bRangeSl := strings.Split(ctx.Get("Range"), "=")
|
||||
@@ -83,27 +82,27 @@ func (c S3ApiController) GetActions(ctx *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
res, code := c.be.GetObject(bucket, key, int64(startOffset), int64(length), ctx.Response().BodyWriter(), "")
|
||||
return responce[*s3.GetObjectOutput](ctx, res, code)
|
||||
return responce(ctx, res, code)
|
||||
}
|
||||
|
||||
func (c S3ApiController) ListActions(ctx *fiber.Ctx) error {
|
||||
if ctx.Request().URI().QueryArgs().Has("acl") {
|
||||
res, code := c.be.GetBucketAcl(ctx.Params("bucket"))
|
||||
return responce[*s3.GetBucketAclOutput](ctx, res, code)
|
||||
return responce(ctx, res, code)
|
||||
}
|
||||
|
||||
if ctx.Request().URI().QueryArgs().Has("uploads") {
|
||||
res, code := c.be.ListMultipartUploads(&s3.ListMultipartUploadsInput{Bucket: aws.String(ctx.Params("bucket"))})
|
||||
return responce[*s3.ListMultipartUploadsOutput](ctx, res, code)
|
||||
return responce(ctx, res, code)
|
||||
}
|
||||
|
||||
if ctx.QueryInt("list-type") == 2 {
|
||||
res, code := c.be.ListObjectsV2(ctx.Params("bucket"), "", "", "", 1)
|
||||
return responce[*s3.ListBucketsOutput](ctx, res, code)
|
||||
return responce(ctx, res, code)
|
||||
}
|
||||
|
||||
res, code := c.be.ListObjects(ctx.Params("bucket"), "", "", "", 1)
|
||||
return responce[*s3.ListBucketsOutput](ctx, res, code)
|
||||
return responce(ctx, res, code)
|
||||
}
|
||||
|
||||
func (c S3ApiController) PutBucketActions(ctx *fiber.Ctx) error {
|
||||
@@ -132,11 +131,11 @@ func (c S3ApiController) PutBucketActions(ctx *fiber.Ctx) error {
|
||||
GrantWriteACP: &grantWriteACP,
|
||||
})
|
||||
|
||||
return responce[internal.Any](ctx, nil, code)
|
||||
return responce[any](ctx, nil, code)
|
||||
}
|
||||
|
||||
code := c.be.PutBucket(bucket)
|
||||
return responce[internal.Any](ctx, nil, code)
|
||||
return responce[any](ctx, nil, code)
|
||||
}
|
||||
|
||||
func (c S3ApiController) PutActions(ctx *fiber.Ctx) error {
|
||||
@@ -193,13 +192,13 @@ func (c S3ApiController) PutActions(ctx *fiber.Ctx) error {
|
||||
CopySourceIfUnmodifiedSince: ©SrcUnmodifSinceDate,
|
||||
})
|
||||
|
||||
return responce[*s3.UploadPartCopyOutput](ctx, res, code)
|
||||
return responce(ctx, res, code)
|
||||
}
|
||||
|
||||
if uploadId != "" {
|
||||
body := io.ReadSeeker(bytes.NewReader([]byte(ctx.Body())))
|
||||
res, code := c.be.UploadPart(dstBucket, dstKeyStart, uploadId, body)
|
||||
return responce[*s3.UploadPartOutput](ctx, res, code)
|
||||
return responce(ctx, res, code)
|
||||
}
|
||||
|
||||
if grants != "" || acl != "" {
|
||||
@@ -217,7 +216,7 @@ func (c S3ApiController) PutActions(ctx *fiber.Ctx) error {
|
||||
GrantWrite: &granWrite,
|
||||
GrantWriteACP: &grantWriteACP,
|
||||
})
|
||||
return responce[internal.Any](ctx, nil, code)
|
||||
return responce[any](ctx, nil, code)
|
||||
}
|
||||
|
||||
if copySource != "" {
|
||||
@@ -225,16 +224,16 @@ func (c S3ApiController) PutActions(ctx *fiber.Ctx) error {
|
||||
srcBucket, srcObject := copySourceSplit[0], copySourceSplit[1:]
|
||||
|
||||
res, code := c.be.CopyObject(srcBucket, strings.Join(srcObject, "/"), dstBucket, dstKeyStart)
|
||||
return responce[*s3.CopyObjectOutput](ctx, res, code)
|
||||
return responce(ctx, res, code)
|
||||
}
|
||||
|
||||
res, code := c.be.PutObject(dstBucket, dstKeyStart, bytes.NewReader(ctx.Request().Body()))
|
||||
return responce[string](ctx, res, code)
|
||||
return responce(ctx, res, code)
|
||||
}
|
||||
|
||||
func (c S3ApiController) DeleteBucket(ctx *fiber.Ctx) error {
|
||||
code := c.be.DeleteBucket(ctx.Params("bucket"))
|
||||
return responce[internal.Any](ctx, nil, code)
|
||||
return responce[any](ctx, nil, code)
|
||||
}
|
||||
|
||||
func (c S3ApiController) DeleteObjects(ctx *fiber.Ctx) error {
|
||||
@@ -244,7 +243,7 @@ func (c S3ApiController) DeleteObjects(ctx *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
code := c.be.DeleteObjects(ctx.Params("bucket"), &s3.DeleteObjectsInput{Delete: &dObj})
|
||||
return responce[internal.Any](ctx, nil, code)
|
||||
return responce[any](ctx, nil, code)
|
||||
}
|
||||
|
||||
func (c S3ApiController) DeleteActions(ctx *fiber.Ctx) error {
|
||||
@@ -264,16 +263,16 @@ func (c S3ApiController) DeleteActions(ctx *fiber.Ctx) error {
|
||||
ExpectedBucketOwner: &expectedBucketOwner,
|
||||
RequestPayer: types.RequestPayer(requestPayer),
|
||||
})
|
||||
return responce[internal.Any](ctx, nil, code)
|
||||
return responce[any](ctx, nil, code)
|
||||
}
|
||||
|
||||
code := c.be.DeleteObject(bucket, key)
|
||||
return responce[internal.Any](ctx, nil, code)
|
||||
return responce[any](ctx, nil, code)
|
||||
}
|
||||
|
||||
func (c S3ApiController) HeadBucket(ctx *fiber.Ctx) error {
|
||||
res, code := c.be.HeadBucket(ctx.Params("bucket"))
|
||||
return responce[*s3.HeadBucketOutput](ctx, res, code)
|
||||
return responce(ctx, res, code)
|
||||
}
|
||||
|
||||
func (c S3ApiController) HeadObject(ctx *fiber.Ctx) error {
|
||||
@@ -283,7 +282,7 @@ func (c S3ApiController) HeadObject(ctx *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
res, code := c.be.HeadObject(bucket, key, "")
|
||||
return responce[*s3.HeadObjectOutput](ctx, res, code)
|
||||
return responce(ctx, res, code)
|
||||
}
|
||||
|
||||
func (c S3ApiController) CreateActions(ctx *fiber.Ctx) error {
|
||||
@@ -296,7 +295,7 @@ func (c S3ApiController) CreateActions(ctx *fiber.Ctx) error {
|
||||
|
||||
if err := xml.Unmarshal(ctx.Body(), &restoreRequest); err == nil {
|
||||
code := c.be.RestoreObject(bucket, key, &restoreRequest)
|
||||
return responce[internal.Any](ctx, nil, code)
|
||||
return responce[any](ctx, nil, code)
|
||||
}
|
||||
|
||||
if uploadId != "" {
|
||||
@@ -307,10 +306,10 @@ func (c S3ApiController) CreateActions(ctx *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
res, code := c.be.CompleteMultipartUpload(bucket, "", uploadId, parts)
|
||||
return responce[*s3.CompleteMultipartUploadOutput](ctx, res, code)
|
||||
return responce(ctx, res, code)
|
||||
}
|
||||
res, code := c.be.CreateMultipartUpload(&s3.CreateMultipartUploadInput{Bucket: &bucket, Key: &key})
|
||||
return responce[*s3.CreateMultipartUploadOutput](ctx, res, code)
|
||||
return responce(ctx, res, code)
|
||||
}
|
||||
|
||||
func responce[R comparable](ctx *fiber.Ctx, resp R, code s3err.ErrorCode) error {
|
||||
|
||||
Reference in New Issue
Block a user