s3

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbortMultipartUploadRequest

type AbortMultipartUploadRequest struct {
	Bucket   string
	Key      string
	UploadID string
}

AbortMultipartUploadRequest represents a request to abort a multipart upload

type CompleteMultipartUploadRequest

type CompleteMultipartUploadRequest struct {
	Bucket   string
	Key      string
	UploadID string
	Parts    []CompletePart
}

CompleteMultipartUploadRequest represents a request to complete a multipart upload

type CompleteMultipartUploadResponse

type CompleteMultipartUploadResponse struct {
	Location string
	Bucket   string
	Key      string
	ETag     string
}

CompleteMultipartUploadResponse represents the response from completing a multipart upload

type CompletePart

type CompletePart struct {
	PartNumber int
	ETag       string
}

CompletePart represents a part in the complete multipart upload request

type CopyObjectRequest

type CopyObjectRequest struct {
	SourceBucket   string
	SourceKey      string
	DestBucket     string
	DestKey        string
	ContentType    string
	CustomMetadata map[string]string
}

CopyObjectRequest represents a request to copy an object between locations. ContentType and CustomMetadata are always applied verbatim to the destination object — callers wanting AWS's default COPY metadata-directive semantics should pass the source's own content-type/metadata (e.g. from a prior HeadObject), and callers wanting REPLACE semantics should pass the metadata extracted from the copy request instead. The service layer has no opinion on which; that's an HTTP-level (x-amz-metadata-directive) concern.

type CreateBucketRequest

type CreateBucketRequest struct {
	Name         string
	Owner        string                   // User who owns the bucket
	BucketPolicy *metadata.PolicyDocument // Optional bucket policy
}

CreateBucketRequest represents a request to create a new bucket

type CreateMultipartUploadRequest

type CreateMultipartUploadRequest struct {
	Bucket         string
	Key            string
	ContentType    string
	CustomMetadata map[string]string
}

CreateMultipartUploadRequest represents a request to initiate a multipart upload

type CreateMultipartUploadResponse

type CreateMultipartUploadResponse struct {
	UploadID string
	Bucket   string
	Key      string
}

CreateMultipartUploadResponse represents the response from initiating a multipart upload

type DeleteObjectRequest

type DeleteObjectRequest struct {
	Bucket string
	Key    string
}

DeleteObjectRequest represents a request to delete an object

type DeleteObjectsRequest

type DeleteObjectsRequest struct {
	Bucket  string
	Objects []s3types.ObjectIdentifier
	Quiet   bool // If true, only return errors in response
}

DeleteObjectsRequest represents a request to delete multiple objects

type DeleteObjectsResponse

type DeleteObjectsResponse struct {
	Deleted []s3types.DeletedObject
	Errors  []s3types.DeleteError
}

DeleteObjectsResponse represents the response from deleting multiple objects

type GetObjectRequest

type GetObjectRequest struct {
	Bucket string
	Key    string
}

GetObjectRequest represents a request to download an object

type GetObjectResponse

type GetObjectResponse struct {
	Content        ObjectReader
	ContentType    string
	Size           int64
	ETag           string
	LastModified   time.Time
	CustomMetadata map[string]string
}

GetObjectResponse represents the response from downloading an object

type GetObjectTaggingRequest

type GetObjectTaggingRequest struct {
	Bucket string
	Key    string
}

GetObjectTaggingRequest represents a request to get tags from an object

type HeadObjectRequest

type HeadObjectRequest struct {
	Bucket string
	Key    string
}

HeadObjectRequest represents a request to get object metadataManager

type HeadObjectResponse

type HeadObjectResponse struct {
	ContentType    string
	Size           int64
	ETag           string
	LastModified   time.Time
	CustomMetadata map[string]string
}

HeadObjectResponse represents object metadataManager

type ListObjectsRequest

type ListObjectsRequest struct {
	Bucket    string
	Prefix    string
	Marker    string
	Delimiter string
	MaxKeys   int
}

ListObjectsRequest represents a request to list objects in a bucket

type ListObjectsV2Request

type ListObjectsV2Request struct {
	Bucket            string
	Prefix            string
	ContinuationToken string
	StartAfter        string
	Delimiter         string
	MaxKeys           int
	FetchOwner        bool
}

ListObjectsV2Request represents a request to list objects (V2)

type ListPartsRequest

type ListPartsRequest struct {
	Bucket   string
	Key      string
	UploadID string
	MaxParts int
}

ListPartsRequest represents a request to list parts in a multipart upload

type ListPartsResponse

type ListPartsResponse struct {
	Bucket   string
	Key      string
	UploadID string
	Parts    []Part
}

ListPartsResponse represents the response from listing parts

type ObjectReader

type ObjectReader interface {
	io.ReadCloser
	io.ReaderAt
}

type OwnerInfo

type OwnerInfo struct {
	OwnerUUID *uuid.UUID
	AccessKey string
	Username  string
}

OwnerInfo carries the resolved ownership of a bucket or object. OwnerUUID is nil for admin-owned resources. AccessKey and Username are populated when the owner is a known IAM user.

type Part

type Part struct {
	PartNumber   int
	ETag         string
	Size         int64
	LastModified time.Time
}

Part represents a single part in a multipart upload

type PutBucketPolicyRequest

type PutBucketPolicyRequest struct {
	Bucket         string
	PolicyDocument *iam.PolicyDocument
}

PutBucketPolicyRequest contains parameters for setting a bucket policy

type PutObjectRequest

type PutObjectRequest struct {
	Bucket         string
	Key            string
	Content        io.Reader
	ContentType    string
	CustomMetadata map[string]string // S3 metadataManager headers (Cache-Control, x-amz-meta-*, etc.)
}

PutObjectRequest represents a request to upload an object

type PutObjectTaggingRequest

type PutObjectTaggingRequest struct {
	Bucket string
	Key    string
	Tags   map[string]string
}

PutObjectTaggingRequest represents a request to set tags on an object

type Service

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

Service provides S3 operations for buckets and objects

func NewService

func NewService(diskStorage *storage.Storage, metadataManager *metadata.Manager, policyEngine *policy.Engine) *Service

NewService creates a new S3 service

func (*Service) AbortMultipartUpload

func (s *Service) AbortMultipartUpload(ctx context.Context, req *AbortMultipartUploadRequest) error

AbortMultipartUpload aborts a multipart upload and cleans up all parts

func (*Service) CompleteMultipartUpload

CompleteMultipartUpload completes a multipart upload by assembling all parts

func (*Service) CopyObject

func (s *Service) CopyObject(ctx context.Context, req *CopyObjectRequest) (string, error)

CopyObject copies an object from one location to another, applying req.ContentType/req.CustomMetadata to the destination regardless of what the source object's own metadata was — see CopyObjectRequest for why that choice is made by the caller, not here.

func (*Service) CreateBucket

func (s *Service) CreateBucket(ctx context.Context, req *CreateBucketRequest) (*metadata.BucketMetadata, error)

CreateBucket creates a new bucket with validation

func (*Service) CreateMultipartUpload

CreateMultipartUpload initiates a multipart upload

func (*Service) DeleteBucket

func (s *Service) DeleteBucket(ctx context.Context, bucket string) error

DeleteBucket deletes a bucket Note: Assumes the caller has validated bucket name

func (*Service) DeleteBucketPolicy

func (s *Service) DeleteBucketPolicy(ctx context.Context, bucket string) error

DeleteBucketPolicy removes the bucket policy

func (*Service) DeleteObject

func (s *Service) DeleteObject(ctx context.Context, req *DeleteObjectRequest) error

DeleteObject deletes an object from a bucket Per S3 spec, this is idempotent - returns success even if object doesn't exist Note: Assumes bucket and key have been validated by the caller

func (*Service) DeleteObjects

func (s *Service) DeleteObjects(ctx context.Context, request *DeleteObjectsRequest) (*DeleteObjectsResponse, error)

DeleteObjects deletes multiple objects in a single request Returns a top-level error for request-level failures (invalid request, bucket not found, etc.) Per-object deletion failures are collected in the response's Errors slice

func (*Service) GetBucket

func (s *Service) GetBucket(ctx context.Context, bucket string) (*metadata.BucketMetadata, error)

GetBucket retrieves bucket metadata. Note: Assumes the caller has validated bucket name

func (*Service) GetBucketLocation

func (s *Service) GetBucketLocation(ctx context.Context, bucket string) (string, error)

GetBucketLocation returns the bucket location (region) Note: Assumes the caller has validated bucket name

func (*Service) GetBucketOwner

func (s *Service) GetBucketOwner(ctx context.Context, bucket string) (*OwnerInfo, error)

GetBucketOwner resolves full ownership information for a bucket. OwnerInfo.OwnerUUID is nil for admin-owned buckets; AccessKey and Username are populated when the owner is a known IAM user.

func (*Service) GetBucketPolicy

func (s *Service) GetBucketPolicy(ctx context.Context, bucket string) (*iam.PolicyDocument, error)

GetBucketPolicy retrieves the bucket policy

func (*Service) GetObject

func (s *Service) GetObject(ctx context.Context, req *GetObjectRequest) (*GetObjectResponse, error)

GetObject downloads an object from a bucket Note: Assumes bucket and key have been validated by the caller

func (*Service) GetObjectOwner

func (s *Service) GetObjectOwner(ctx context.Context, bucket, key string) (*OwnerInfo, error)

GetObjectOwner resolves full ownership information for an object. Returns s3types.ErrBucketNotFound or s3types.ErrObjectNotFound as appropriate.

func (*Service) GetObjectOwnerUUID

func (s *Service) GetObjectOwnerUUID(ctx context.Context, bucket, key string) (*uuid.UUID, error)

GetObjectOwnerUUID returns the owner UUID of an object, or nil if unset (admin-owned). Returns s3types.ErrBucketNotFound when the bucket does not exist, and s3types.ErrObjectNotFound when the key does not exist within the bucket.

func (*Service) GetObjectTagging

func (s *Service) GetObjectTagging(ctx context.Context, req *GetObjectTaggingRequest) (map[string]string, error)

GetObjectTagging retrieves tags from an object

func (*Service) GetObjectWithRange

func (s *Service) GetObjectWithRange(ctx context.Context, bucket, key string, start, end int64) (io.ReadCloser, error)

GetObjectWithRange retrieves part of an object (for range requests) Note: This is a placeholder for future implementation

func (*Service) HeadBucket

func (s *Service) HeadBucket(ctx context.Context, bucket string) (bool, error)

HeadBucket checks if a bucket exists Note: Assumes the caller has validated bucket name

func (*Service) HeadObject

func (s *Service) HeadObject(ctx context.Context, req *HeadObjectRequest) (*HeadObjectResponse, error)

HeadObject retrieves object metadataManager without downloading the object Note: Assumes bucket and key have been validated by the caller

func (*Service) ListBuckets

func (s *Service) ListBuckets(ctx context.Context) ([]s3types.Bucket, error)

ListBuckets returns all buckets

func (*Service) ListBucketsWithMetadata

func (s *Service) ListBucketsWithMetadata(ctx context.Context) ([]*metadata.BucketMetadata, error)

ListBucketsWithMetadata returns full bucket metadata for every bucket. Used by the console to display ownership information alongside bucket names.

func (*Service) ListObjects

func (s *Service) ListObjects(ctx context.Context, req *ListObjectsRequest) (storage.InternalResult, error)

ListObjects lists objects in a bucket (V1) Note: Assumes bucket name has been validated by the caller

func (*Service) ListObjectsV2

func (s *Service) ListObjectsV2(ctx context.Context, req *ListObjectsV2Request) (storage.InternalResult, error)

ListObjectsV2 lists objects in a bucket (V2) Note: Assumes bucket name has been validated by the caller

func (*Service) ListParts

func (s *Service) ListParts(ctx context.Context, req *ListPartsRequest) (*ListPartsResponse, error)

ListParts lists all parts for a multipart upload

func (*Service) ObjectExists

func (s *Service) ObjectExists(ctx context.Context, bucket, key string) (bool, error)

ObjectExists checks if an object exists in a bucket

func (*Service) PutBucketPolicy

func (s *Service) PutBucketPolicy(ctx context.Context, req *PutBucketPolicyRequest) error

PutBucketPolicy sets or updates a bucket policy

func (*Service) PutObject

func (s *Service) PutObject(ctx context.Context, req *PutObjectRequest) (string, error)

PutObject uploads an object to a bucket Note: Assumes the caller has validated bucket and key

func (*Service) PutObjectTagging

func (s *Service) PutObjectTagging(ctx context.Context, req *PutObjectTaggingRequest) error

PutObjectTagging sets tags on an object

func (*Service) SetBucketOwner

func (s *Service) SetBucketOwner(ctx context.Context, bucket string, ownerUUID *uuid.UUID) error

SetBucketOwner updates the owner UUID of an existing bucket.

func (*Service) UploadPart

func (s *Service) UploadPart(ctx context.Context, req *UploadPartRequest) (*UploadPartResponse, error)

UploadPart uploads a single part for a multipart upload

type UpdateBucketRequest

type UpdateBucketRequest struct {
	BucketPolicy *metadata.PolicyDocument // Update bucket policy
}

UpdateBucketRequest represents a request to update bucket metadataManager

type UploadPartRequest

type UploadPartRequest struct {
	Bucket     string
	Key        string
	UploadID   string
	PartNumber int
	Content    io.Reader
}

UploadPartRequest represents a request to upload a part

type UploadPartResponse

type UploadPartResponse struct {
	ETag string
}

UploadPartResponse represents the response from uploading a part

Jump to

Keyboard shortcuts

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