diff --git a/s3api/controllers/base.go b/s3api/controllers/base.go index 2b8bb9c..e4ecbae 100644 --- a/s3api/controllers/base.go +++ b/s3api/controllers/base.go @@ -15,7 +15,6 @@ package controllers import ( - "bytes" "encoding/xml" "errors" "fmt" @@ -2186,7 +2185,7 @@ func (c S3ApiController) PutActions(ctx *fiber.Ctx) error { if bodyi != nil { body = bodyi.(io.Reader) } else { - body = bytes.NewReader([]byte{}) + body = ctx.Request().BodyStream() } res, err := c.be.UploadPart(ctx.Context(), @@ -2659,7 +2658,7 @@ func (c S3ApiController) PutActions(ctx *fiber.Ctx) error { if bodyi != nil { body = bodyi.(io.Reader) } else { - body = bytes.NewReader([]byte{}) + body = ctx.Request().BodyStream() } res, err := c.be.PutObject(ctx.Context(), @@ -3924,6 +3923,7 @@ func SendResponse(ctx *fiber.Ctx, err error, l *MetaOpts) error { ctx.Status(apierr.HTTPStatusCode) return ctx.Send(s3err.GetAPIErrorResponse(apierr, "", "", "")) } + fmt.Println(err, "------------") fmt.Fprintf(os.Stderr, "Internal Error, %v\n", err) ctx.Status(http.StatusInternalServerError) diff --git a/s3api/middlewares/public-bucket.go b/s3api/middlewares/public-bucket.go index ebf7230..e32e755 100644 --- a/s3api/middlewares/public-bucket.go +++ b/s3api/middlewares/public-bucket.go @@ -79,6 +79,25 @@ func AuthorizePublicBucketAccess(be backend.Backend, s3action string, policyPerm } } + if utils.IsBigDataAction(ctx) { + payloadType := ctx.Get("X-Amz-Content-Sha256") + if utils.IsUnsignedStreamingPayload(payloadType) { + checksumType, err := utils.ExtractChecksumType(ctx) + if err != nil { + return sendResponse(ctx, err, l, mm) + } + + wrapBodyReader(ctx, func(r io.Reader) io.Reader { + var cr io.Reader + cr, err = utils.NewUnsignedChunkReader(r, checksumType) + return cr + }) + if err != nil { + return sendResponse(ctx, err, l, mm) + } + } + } + utils.ContextKeyPublicBucket.Set(ctx, true) return nil