s3

package
v0.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WriteErrorResponse = httpresponse.WriteErrorResponse

WriteErrorResponse writes an S3 error response in XML format. It is exported so that middleware can use it for validation errors.

View Source
var WriteXMLResponse = httpresponse.WriteXMLResponse

WriteXMLResponse writes an S3 response in XML format. It is exported so that middleware can use it.

Functions

This section is empty.

Types

type HTTPHandler

type HTTPHandler struct {
	// contains filtered or unexported fields
}

HTTPHandler handles S3 API requests

func New

func New(
	serviceFactory *service.ServicesFactory,
	urlBuilder URLBuilder,
	adminKeys policy.AdminKeyChecker,
) *HTTPHandler

New creates a new S3 API handler

func (*HTTPHandler) AbortMultipartUpload

func (h *HTTPHandler) AbortMultipartUpload(w http.ResponseWriter, r *http.Request, bucket, key string)

AbortMultipartUpload aborts a multipart upload and cleans up all parts

func (*HTTPHandler) CompleteMultipartUpload

func (h *HTTPHandler) CompleteMultipartUpload(w http.ResponseWriter, r *http.Request, bucket, key string)

CompleteMultipartUpload completes a multipart upload by assembling all parts

func (*HTTPHandler) CopyObject

func (h *HTTPHandler) CopyObject(w http.ResponseWriter, r *http.Request, bucket, key string)

CopyObject handles PUT /{bucket}/{key} with X-Amz-Copy-Source header.

Note on addressing style: the destination bucket/key here are already resolved by the same path- or vhost-style routeStyle as every other object handler (see routes.go's object()/routeStyle) — CopyObject gets no special treatment there. The *source*, however, always comes from the X-Amz-Copy-Source header value, which per the S3 API spec is always a literal "/bucket/key" string — it has no Host component and is never vhost-addressed, even when the request that carries it reached DirIO via vhost-style. That's not a routing gap; there is no vhost equivalent of this header because AWS itself never defined one.

func (*HTTPHandler) CreateBucket

func (h *HTTPHandler) CreateBucket(w http.ResponseWriter, r *http.Request, bucket string)

CreateBucket handles PUT /{bucket}

func (*HTTPHandler) CreateMultipartUpload

func (h *HTTPHandler) CreateMultipartUpload(w http.ResponseWriter, r *http.Request, bucket, key string)

CreateMultipartUpload initiates a multipart upload

func (*HTTPHandler) DeleteBucket

func (h *HTTPHandler) DeleteBucket(w http.ResponseWriter, r *http.Request, bucket string)

DeleteBucket handles DELETE /{bucket} TODO(Phase 3.2 #2): Fix 405 Method Not Allowed for MinIO mc client

  • Currently returns 405 for MinIO mc, but policy engine is ready (s3:DeleteBucket)
  • Likely a routing issue, not authorization - check teapot-router DELETE route registration
  • Test: mc rb alias/bucket
  • Verify route matches in routes.go line ~293: r.DELETE("/{bucket}", ...)

func (*HTTPHandler) DeleteBucketPolicy

func (h *HTTPHandler) DeleteBucketPolicy(w http.ResponseWriter, r *http.Request, bucket string)

DeleteBucketPolicy handles DELETE /{bucket}?policy

func (*HTTPHandler) DeleteObject

func (h *HTTPHandler) DeleteObject(w http.ResponseWriter, r *http.Request, bucket, key string)

DeleteObject handles DELETE /{bucket}/{key} TODO(Phase 3.2 #1): Fix 405 Method Not Allowed for MinIO mc client

  • Currently returns 405 for MinIO mc, but policy engine is ready (s3:DeleteObject)
  • Likely a routing issue, not authorization - check teapot-router DELETE route registration
  • Test: mc rm alias/bucket/object.txt
  • Verify route matches in routes.go line ~340: r.DELETE("/{bucket}/{key:.*}", ...)

func (*HTTPHandler) DeleteObjects

func (h *HTTPHandler) DeleteObjects(w http.ResponseWriter, r *http.Request, bucket string)

func (*HTTPHandler) GetBucketLocation

func (h *HTTPHandler) GetBucketLocation(w http.ResponseWriter, r *http.Request, bucket string)

GetBucketLocation handles GET /{bucket}?location

func (*HTTPHandler) GetBucketPolicy

func (h *HTTPHandler) GetBucketPolicy(w http.ResponseWriter, r *http.Request, bucket string)

GetBucketPolicy handles GET /{bucket}?policy

func (*HTTPHandler) GetObject

func (h *HTTPHandler) GetObject(w http.ResponseWriter, r *http.Request, bucket, key string)

GetObject handles GET /{bucket}/{key}

func (*HTTPHandler) GetObjectTagging

func (h *HTTPHandler) GetObjectTagging(w http.ResponseWriter, r *http.Request, bucket, key string)

GetObjectTagging handles GET /{bucket}/{key}?tagging Returns the tags associated with an object

func (*HTTPHandler) HeadBucket

func (h *HTTPHandler) HeadBucket(w http.ResponseWriter, r *http.Request, bucket string)

HeadBucket handles HEAD /{bucket}

func (*HTTPHandler) HeadObject

func (h *HTTPHandler) HeadObject(w http.ResponseWriter, r *http.Request, bucket, key string)

HeadObject handles HEAD /{bucket}/{key}

func (*HTTPHandler) ListBuckets

func (h *HTTPHandler) ListBuckets(w http.ResponseWriter, r *http.Request)

ListBuckets handles GET / (list all buckets; for the root index route)

func (*HTTPHandler) ListObjects

func (h *HTTPHandler) ListObjects(w http.ResponseWriter, r *http.Request, bucket string)

ListObjects handles GET /{bucket} (ListObjectsV1)

func (*HTTPHandler) ListObjectsV2

func (h *HTTPHandler) ListObjectsV2(w http.ResponseWriter, r *http.Request, bucket string)

ListObjectsV2 handles GET /{bucket}?list-type=2

func (*HTTPHandler) ListParts

func (h *HTTPHandler) ListParts(w http.ResponseWriter, r *http.Request, bucket, key string)

ListParts lists all uploaded parts for a multipart upload

func (*HTTPHandler) PostObject

func (h *HTTPHandler) PostObject(w http.ResponseWriter, r *http.Request, bucket string)

PostObject handles POST /{bucket} — S3 POST policy browser-based form upload.

Auth middleware has already verified the signature and stored the authenticated user and the base64-encoded policy document in the request context. This handler:

  1. Retrieves the policy document from context and parses it
  2. Extracts form fields (key, Content-Type, success response options)
  3. Reads the uploaded file from the "file" form field
  4. Validates policy conditions (bucket, key, content-type, content-length-range)
  5. Stores the object via the S3 service
  6. Returns the appropriate success response

func (*HTTPHandler) PutBucketPolicy

func (h *HTTPHandler) PutBucketPolicy(w http.ResponseWriter, r *http.Request, bucket string)

PutBucketPolicy handles PUT /{bucket}?policy

func (*HTTPHandler) PutObject

func (h *HTTPHandler) PutObject(w http.ResponseWriter, r *http.Request, bucket, key string)

PutObject handles PUT /{bucket}/{key}

func (*HTTPHandler) PutObjectTagging

func (h *HTTPHandler) PutObjectTagging(w http.ResponseWriter, r *http.Request, bucket, key string)

PutObjectTagging handles PUT /{bucket}/{key}?tagging Sets or replaces tags on an existing object

func (*HTTPHandler) UploadPart

func (h *HTTPHandler) UploadPart(w http.ResponseWriter, r *http.Request, bucket, key string)

UploadPart uploads a single part for a multipart upload

func (*HTTPHandler) UploadPartCopy

func (h *HTTPHandler) UploadPartCopy(w http.ResponseWriter, r *http.Request, bucket, key string)

UploadPartCopy copies data from an existing object as a part in a multipart upload

type URLBuilder

type URLBuilder interface {
	BucketURL(r *http.Request, bucket string) string
	ObjectURL(r *http.Request, bucket, key string) string
}

URLBuilder defines the interface for generating URLs in S3 API responses

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL