s3api

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BucketsResult

type BucketsResult struct {
	XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListAllMyBucketsResult"`
	Owner   *s3.Owner
	Buckets []*s3.Bucket `xml:"Buckets>Bucket"`
}

BucketsResult is the XML envelope for ListBuckets responses.

type CopyObjectResult

type CopyObjectResult struct {
	ETag           string    `xml:"ETag"`
	LastModified   time.Time `xml:"LastModified"`
	ChecksumCRC32  string    `xml:"ChecksumCRC32"`
	ChecksumCRC32C string    `xml:"ChecksumCRC32C"`
	ChecksumSHA1   string    `xml:"ChecksumSHA1"`
	ChecksumSHA256 string    `xml:"ChecksumSHA256"`
}

CopyObjectResult is a compact response shape used by some S3 clients to acknowledge a successful object write/copy with an ETag.

type DeleteError added in v0.3.2

type DeleteError struct {
	Key       string `xml:"Key"`
	Code      string `xml:"Code"`
	Message   string `xml:"Message"`
	VersionId string `xml:"VersionId,omitempty"`
}

DeleteError represents an error during object deletion.

type DeleteRequest added in v0.3.2

type DeleteRequest struct {
	XMLName xml.Name         `xml:"Delete"`
	Objects []ObjectToDelete `xml:"Object"`
	Quiet   bool             `xml:"Quiet"`
}

DeleteRequest represents the S3 DeleteObjects request structure.

type DeleteResult added in v0.3.2

type DeleteResult struct {
	XMLName xml.Name        `xml:"http://s3.amazonaws.com/doc/2006-03-01/ DeleteResult"`
	Deleted []DeletedObject `xml:"Deleted,omitempty"`
	Error   []DeleteError   `xml:"Error,omitempty"`
}

DeleteResult represents the S3 DeleteObjects response structure.

type DeletedObject added in v0.3.2

type DeletedObject struct {
	Key       string `xml:"Key"`
	VersionId string `xml:"VersionId,omitempty"`
}

DeletedObject represents a successfully deleted object.

type ListBucketResult

type ListBucketResult struct {
	IsTruncated    bool          `xml:"IsTruncated"`
	Contents       []s3.Object   `xml:"Contents"`
	Name           string        `xml:"Name"`
	Prefix         string        `xml:"Prefix"`
	Delimiter      string        `xml:"Delimiter,omitempty"`
	MaxKeys        int           `xml:"MaxKeys"`
	CommonPrefixes []PrefixEntry `xml:"CommonPrefixes,omitempty"`
}

ListBucketResult is a minimal representation of S3's ListBucket result.

type LocationConstraintResponse added in v0.3.6

type LocationConstraintResponse struct {
	XMLName  xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ LocationConstraint"`
	Location string   `xml:",chardata"`
}

LocationConstraintResponse is the XML response for GetBucketLocation.

type ObjectToDelete added in v0.3.2

type ObjectToDelete struct {
	Key       string `xml:"Key"`
	VersionId string `xml:"VersionId,omitempty"`
}

ObjectToDelete represents an object to be deleted.

type PrefixEntry added in v0.3.2

type PrefixEntry struct {
	Prefix string `xml:"Prefix"`
}

PrefixEntry represents a common prefix in S3 list results.

type S3Gateway

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

S3Gateway registers S3-compatible HTTP routes (2006-03-01) and delegates implemented operations to NATS JetStream-backed object storage. Unimplemented endpoints intentionally respond with HTTP 501 Not Implemented.

func NewS3Gateway

func NewS3Gateway(logger log.Logger,
	natsServers string,
	replicas int,
	natsOptions []nats.Option,
	credStore credential.Store) (*S3Gateway, error)

NewS3Gateway creates a gateway instance and establishes a connection to NATS using the given servers and connection options. Returns an error if initialization fails.

func (*S3Gateway) AbortMultipartUpload added in v0.3.1

func (s *S3Gateway) AbortMultipartUpload(w http.ResponseWriter, r *http.Request)

AbortMultipartUpload aborts a multipart upload, removing uploaded parts and session metadata, and responds with 204 No Content on success.

func (*S3Gateway) Close added in v0.4.1

func (s *S3Gateway) Close()

Close closes the underlying NATS connection.

func (*S3Gateway) CompleteMultipartUpload added in v0.3.1

func (s *S3Gateway) CompleteMultipartUpload(w http.ResponseWriter, r *http.Request)

CompleteMultipartUpload finalizes a multipart upload by parsing the client provided part list, delegating composition to the storage client, and returning an S3-compatible XML response with the final ETag.

func (*S3Gateway) CopyObject added in v0.3.2

func (s *S3Gateway) CopyObject(w http.ResponseWriter, r *http.Request)

CopyObject performs a server-side copy of an object from source to destination.

func (*S3Gateway) CreateBucket

func (s *S3Gateway) CreateBucket(w http.ResponseWriter, r *http.Request)

CreateBucket handles S3 CreateBucket by creating a JetStream Object Store bucket and returning a minimal S3-compatible XML response.

func (*S3Gateway) DeleteBucket

func (s *S3Gateway) DeleteBucket(w http.ResponseWriter, r *http.Request)

DeleteBucket deletes the specified bucket and responds with 204 No Content. Returns NoSuchBucket if the bucket does not exist. Returns BucketNotEmpty if the bucket contains objects.

func (*S3Gateway) DeleteObject

func (s *S3Gateway) DeleteObject(w http.ResponseWriter, r *http.Request)

DeleteObject deletes the specified object and responds with 204 No Content.

func (*S3Gateway) DeleteObjectTagging added in v0.4.0

func (s *S3Gateway) DeleteObjectTagging(w http.ResponseWriter, r *http.Request)

DeleteObjectTagging removes all tags from an object.

func (*S3Gateway) DeleteObjects added in v0.3.2

func (s *S3Gateway) DeleteObjects(w http.ResponseWriter, r *http.Request)

DeleteObjects handles batch deletion of multiple objects in a single request.

func (*S3Gateway) Download

func (s *S3Gateway) Download(w http.ResponseWriter, r *http.Request)

Download writes object content to the response and sets typical S3 headers such as Last-Modified, ETag, Content-Type, and Content-Length.

func (*S3Gateway) GetBucketLocation added in v0.3.6

func (s *S3Gateway) GetBucketLocation(w http.ResponseWriter, r *http.Request)

GetBucketLocation returns the region where the bucket resides.

func (*S3Gateway) GetObjectAttributes added in v0.3.12

func (s *S3Gateway) GetObjectAttributes(w http.ResponseWriter, r *http.Request)

GetObjectAttributes retrieves metadata attributes for an object. It supports the x-amz-object-attributes header to specify which attributes to return.

func (*S3Gateway) GetObjectRetention added in v0.3.3

func (s *S3Gateway) GetObjectRetention(w http.ResponseWriter, r *http.Request)

GetObjectRetention returns object retention configuration (mode and retain-until-date)

func (*S3Gateway) GetObjectTagging added in v0.4.0

func (s *S3Gateway) GetObjectTagging(w http.ResponseWriter, r *http.Request)

GetObjectTagging retrieves tags associated with an object.

func (*S3Gateway) HeadBucket added in v0.3.7

func (s *S3Gateway) HeadBucket(w http.ResponseWriter, r *http.Request)

HeadBucket checks if a bucket exists and the user has permission to access it. Returns 200 OK if bucket exists, 404 if not found.

func (*S3Gateway) HeadObject

func (s *S3Gateway) HeadObject(w http.ResponseWriter, r *http.Request)

HeadObject writes object metadata headers without a response body.

func (*S3Gateway) Healthz added in v0.3.1

func (s *S3Gateway) Healthz(w http.ResponseWriter, r *http.Request)

Healthz returns 200 OK when the gateway has an active connection to NATS. Returns 503 Service Unavailable when disconnected.

func (*S3Gateway) InitiateMultipartUpload added in v0.3.1

func (s *S3Gateway) InitiateMultipartUpload(w http.ResponseWriter, r *http.Request)

InitiateMultipartUpload creates a new multipart upload session for the given bucket and object key, returning UploadId/Bucket/Key in S3-compatible XML.

func (*S3Gateway) ListBuckets

func (s *S3Gateway) ListBuckets(w http.ResponseWriter, r *http.Request)

ListBuckets enumerates existing JetStream Object Store buckets and returns a simple S3-compatible XML response.

func (*S3Gateway) ListObjects

func (s *S3Gateway) ListObjects(w http.ResponseWriter, r *http.Request)

ListObjects returns objects in a bucket as a simple S3-compatible XML list.

func (*S3Gateway) ListParts added in v0.3.1

func (s *S3Gateway) ListParts(w http.ResponseWriter, r *http.Request)

ListParts lists uploaded parts for a multipart upload. Supports pagination via part-number-marker and max-parts query parameters.

func (*S3Gateway) PutObjectTagging added in v0.4.0

func (s *S3Gateway) PutObjectTagging(w http.ResponseWriter, r *http.Request)

PutObjectTagging sets or replaces tags on an existing object.

func (*S3Gateway) RegisterRoutes

func (s *S3Gateway) RegisterRoutes(router *mux.Router)

RegisterRoutes wires the S3 REST API endpoints onto the provided mux router.

func (*S3Gateway) SetOptionHeaders

func (s *S3Gateway) SetOptionHeaders(w http.ResponseWriter, r *http.Request)

SetOptionHeaders responds to CORS preflight and generic OPTIONS requests with permissive headers to simplify development and testing.

func (*S3Gateway) StreamUpload added in v0.3.8

func (s *S3Gateway) StreamUpload(w http.ResponseWriter, r *http.Request)

StreamUpload handles SigV4 streaming-chunked single PUT uploads.

func (*S3Gateway) StreamUploadPart added in v0.3.8

func (s *S3Gateway) StreamUploadPart(w http.ResponseWriter, r *http.Request)

StreamUploadPart handles SigV4 streaming-chunked multipart uploads.

func (*S3Gateway) UpdateObjectRetention added in v0.3.3

func (s *S3Gateway) UpdateObjectRetention(w http.ResponseWriter, r *http.Request)

UpdateObjectRetention sets object retention configuration (mode and retain-until-date)

func (*S3Gateway) Upload

func (s *S3Gateway) Upload(w http.ResponseWriter, r *http.Request)

Upload stores an object and responds with 200 and an ETag header.

func (*S3Gateway) UploadPart added in v0.3.1

func (s *S3Gateway) UploadPart(w http.ResponseWriter, r *http.Request)

UploadPart receives an object part for an existing multipart upload and responds with the part's ETag in the response headers. The ETag value is quoted to match S3 behavior.

Jump to

Keyboard shortcuts

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