object

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package object object/acl.go

Package object object/append.go

Package object object/compose.go

Package object object/copy.go

Package object object/delete.go

Package object provides object-level operations for the RustFS Go SDK.

It includes upload/download, metadata, tagging, versioning, and advanced object features.

Package object object/errors.go

Package object object/fputget.go

Package object object/get.go

Package object object/list.go

Package object object/lock.go

Package object object/multipart.go

Package object object/object.go

Package object object/options.go

Package object object/post_policy.go

Package object object/presign.go

Package object object/put.go

Package object object/restore.go

Package object object/select.go

Package object object/service.go

Package object object/stat.go

Package object object/tagging.go

Package object object/utils.go

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidBucketName invalid bucket name
	ErrInvalidBucketName = errors.New("invalid bucket name")

	// ErrInvalidObjectName invalid object name
	ErrInvalidObjectName = errors.New("invalid object name")

	// ErrObjectNotFound object not found
	ErrObjectNotFound = errors.New("object not found")

	// ErrListStopped list operation stopped via stop channel
	ErrListStopped = errors.New("list stopped by stop channel")

	// ErrNotImplemented feature not implemented
	ErrNotImplemented = errors.New("not implemented yet")
)

Functions

func WithVersionID

func WithVersionID(versionID string) interface{}

WithVersionID selects a specific object version (Get/Stat/Delete)

Types

type CommonPrefix

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

CommonPrefix represents common prefix entry

type CopyOption

type CopyOption func(*CopyOptions)

CopyOption applies copy option

func WithCopyMetadata

func WithCopyMetadata(metadata map[string]string, replace bool) CopyOption

WithCopyMetadata sets destination metadata for copy

func WithCopySourceVersionID

func WithCopySourceVersionID(versionID string) CopyOption

WithCopySourceVersionID sets the source version ID for a copy

type CopyOptions

type CopyOptions struct {
	// Source version ID
	SourceVersionID string

	// Destination metadata and tags
	UserMetadata map[string]string
	UserTags     map[string]string

	// Replace metadata and/or tagging instead of copying existing
	ReplaceMetadata bool
	ReplaceTagging  bool

	// Object header overrides
	ContentType        string
	ContentEncoding    string
	ContentDisposition string
	CacheControl       string
	Expires            time.Time

	// Storage class
	StorageClass string

	// Conditional copy headers
	MatchETag     string
	NotMatchETag  string
	MatchModified time.Time
	NotModified   time.Time

	// Custom headers
	CustomHeaders http.Header
}

CopyOptions controls server-side copy behavior

type DeleteOption

type DeleteOption func(*DeleteOptions)

DeleteOption applies delete option

type DeleteOptions

type DeleteOptions struct {
	// Version ID
	VersionID string

	// Force delete when possible
	ForceDelete bool

	// Custom headers
	CustomHeaders http.Header
}

DeleteOptions controls object deletion

type DestinationInfo added in v1.0.5

type DestinationInfo struct {
	Bucket string
	Object string
}

DestinationInfo describes the target object for composition.

type GetOption

type GetOption func(*GetOptions)

GetOption applies download option

func WithGetRange

func WithGetRange(start, end int64) GetOption

WithGetRange sets byte range for downloads

func WithGetSSE added in v1.0.5

func WithGetSSE(encrypter sse.Encrypter) GetOption

WithGetSSE sets server-side encryption for downloads of encrypted objects

func WithGetSSEC added in v1.0.5

func WithGetSSEC(key []byte) GetOption

WithGetSSEC enables SSE-C decryption for downloads

func WithGetSSECustomer added in v1.0.3

func WithGetSSECustomer(keyB64, keyMD5 string) GetOption

WithGetSSECustomer sets SSE-C parameters for downloads (key must be base64 encoded)

type GetOptions

type GetOptions struct {
	// Range header
	RangeStart int64
	RangeEnd   int64
	SetRange   bool

	// Version ID
	VersionID string

	// Conditional headers
	MatchETag     string
	NotMatchETag  string
	MatchModified time.Time
	NotModified   time.Time

	// Custom headers
	CustomHeaders http.Header

	// Server-side encryption for encrypted objects
	SSE sse.Encrypter

	// SSE-C headers for encrypted objects (deprecated, use SSE field)
	SSECustomerAlgorithm string
	SSECustomerKey       string
	SSECustomerKeyMD5    string
}

GetOptions controls object download behavior

type LegalHoldOption added in v1.0.5

type LegalHoldOption func(*LegalHoldOptions)

LegalHoldOption applies legal hold options

func WithLegalHoldVersionID added in v1.0.5

func WithLegalHoldVersionID(versionID string) LegalHoldOption

WithLegalHoldVersionID targets a specific object version for legal hold operations.

type LegalHoldOptions added in v1.0.5

type LegalHoldOptions struct {
	VersionID string
}

LegalHoldOptions controls legal hold operations.

type ListBucketV2Result

type ListBucketV2Result struct {
	XMLName               xml.Name           `xml:"ListBucketResult"`
	Name                  string             `xml:"Name"`
	Prefix                string             `xml:"Prefix"`
	KeyCount              int                `xml:"KeyCount"`
	MaxKeys               int                `xml:"MaxKeys"`
	Delimiter             string             `xml:"Delimiter"`
	IsTruncated           bool               `xml:"IsTruncated"`
	Contents              []types.ObjectInfo `xml:"Contents"`
	CommonPrefixes        []CommonPrefix     `xml:"CommonPrefixes"`
	ContinuationToken     string             `xml:"ContinuationToken"`
	NextContinuationToken string             `xml:"NextContinuationToken"`
	StartAfter            string             `xml:"StartAfter"`
}

ListBucketV2Result represents bucket listing V2 response

type ListOption

type ListOption func(*ListOptions)

ListOption applies list option

func WithListMaxKeys

func WithListMaxKeys(maxKeys int) ListOption

WithListMaxKeys sets the maximum keys to return

func WithListMetadata added in v1.0.4

func WithListMetadata(include bool) ListOption

WithListMetadata includes object metadata in list results when supported

func WithListPrefix

func WithListPrefix(prefix string) ListOption

WithListPrefix sets listing prefix

func WithListRecursive

func WithListRecursive(recursive bool) ListOption

WithListRecursive toggles recursive listing

func WithListStopChan added in v1.0.4

func WithListStopChan(ch <-chan struct{}) ListOption

WithListStopChan sets a channel to stop listing early

func WithListVersions added in v1.0.4

func WithListVersions() ListOption

WithListVersions lists object versions instead of current objects

type ListOptions

type ListOptions struct {
	// Prefix filter
	Prefix string

	// Recursive listing
	Recursive bool

	// StopChan is an optional signal channel to stop listing early
	StopChan <-chan struct{}

	// Max keys
	MaxKeys int

	// Start token
	StartAfter string

	// Use ListObjectsV2
	UseV2 bool

	// Include object versions
	WithVersions bool

	// Include object metadata
	WithMetadata bool

	// Custom headers
	CustomHeaders http.Header
}

ListOptions controls object listing

type PresignOption added in v1.0.3

type PresignOption func(*PresignOptions)

PresignOption applies presign options

func WithPresignHeaders added in v1.0.3

func WithPresignHeaders(headers http.Header) PresignOption

WithPresignHeaders adds headers that must be signed for the presigned URL

func WithPresignQuery added in v1.0.3

func WithPresignQuery(values url.Values) PresignOption

WithPresignQuery adds additional query parameters (e.g., response-content-type)

func WithPresignSSECustomer added in v1.0.3

func WithPresignSSECustomer(keyB64, keyMD5 string) PresignOption

WithPresignSSECustomer signs SSE-C headers for presigned requests (key must be base64 encoded)

func WithPresignSSES3 added in v1.0.3

func WithPresignSSES3() PresignOption

WithPresignSSES3 signs SSE-S3 header for presigned requests

type PresignOptions added in v1.0.3

type PresignOptions struct {
	Headers     http.Header
	QueryValues url.Values
}

PresignOptions controls presigned URL generation

type PutOption

type PutOption func(*PutOptions)

PutOption applies upload option

func WithContentDisposition

func WithContentDisposition(disposition string) PutOption

WithContentDisposition sets Content-Disposition

func WithContentEncoding

func WithContentEncoding(encoding string) PutOption

WithContentEncoding sets Content-Encoding

func WithContentType

func WithContentType(contentType string) PutOption

WithContentType sets Content-Type

func WithPartSize

func WithPartSize(size uint64) PutOption

WithPartSize sets multipart part size

func WithSSE added in v1.0.5

func WithSSE(encrypter sse.Encrypter) PutOption

WithSSE sets server-side encryption for uploads

func WithSSEC added in v1.0.5

func WithSSEC(key []byte) PutOption

WithSSEC enables SSE-C (customer-provided key) encryption

func WithSSECustomer added in v1.0.3

func WithSSECustomer(keyB64, keyMD5 string) PutOption

WithSSECustomer provides SSE-C parameters for uploads (key must be base64 encoded)

func WithSSEKMS added in v1.0.5

func WithSSEKMS(keyID string, context map[string]string) PutOption

WithSSEKMS enables SSE-KMS (AWS KMS) encryption

func WithSSES3 added in v1.0.3

func WithSSES3() PutOption

WithSSES3 enables SSE-S3 server-side encryption for uploads

func WithStorageClass

func WithStorageClass(class string) PutOption

WithStorageClass sets storage class

func WithUserMetadata

func WithUserMetadata(metadata map[string]string) PutOption

WithUserMetadata sets user metadata

func WithUserTags

func WithUserTags(tags map[string]string) PutOption

WithUserTags sets object tags

type PutOptions

type PutOptions struct {

	// Content-Type
	ContentType string

	// Content-Encoding
	ContentEncoding string

	// Content-Disposition
	ContentDisposition string

	// Content-Language
	ContentLanguage string

	// Cache-Control
	CacheControl string

	// Expiration time
	Expires time.Time

	// User metadata
	UserMetadata map[string]string

	// User tags
	UserTags map[string]string

	// Storage class
	StorageClass string

	// Custom headers
	CustomHeaders http.Header

	// Whether to send Content-MD5
	SendContentMD5 bool

	// Disable Content-SHA256
	DisableContentSHA256 bool

	// Server-side encryption
	SSE sse.Encrypter

	// SSE-S3 / SSE-C options (deprecated, use SSE field)
	SSECustomerAlgorithm string
	SSECustomerKey       string
	SSECustomerKeyMD5    string

	// Multipart part size
	PartSize uint64

	// Number of concurrent uploads
	NumThreads uint
	// contains filtered or unexported fields
}

PutOptions controls object upload behavior

type RetentionOption added in v1.0.5

type RetentionOption func(*RetentionOptions)

RetentionOption applies retention options

func WithGovernanceBypass added in v1.0.5

func WithGovernanceBypass() RetentionOption

WithGovernanceBypass bypasses governance retention restrictions.

func WithRetentionVersionID added in v1.0.5

func WithRetentionVersionID(versionID string) RetentionOption

WithRetentionVersionID targets a specific object version for retention operations.

type RetentionOptions added in v1.0.5

type RetentionOptions struct {
	VersionID        string
	GovernanceBypass bool
}

RetentionOptions controls retention operations.

type Service

type Service interface {
	// Put uploads an object
	Put(ctx context.Context, bucketName, objectName string, reader io.Reader, objectSize int64, opts ...PutOption) (types.UploadInfo, error)

	// Get downloads an object
	Get(ctx context.Context, bucketName, objectName string, opts ...GetOption) (io.ReadCloser, types.ObjectInfo, error)

	// FPut uploads a file from a local path
	FPut(ctx context.Context, bucketName, objectName, filePath string, opts ...PutOption) (types.UploadInfo, error)

	// FGet downloads an object to a local file path
	FGet(ctx context.Context, bucketName, objectName, filePath string, opts ...GetOption) (types.ObjectInfo, error)

	// Stat retrieves object info
	Stat(ctx context.Context, bucketName, objectName string, opts ...StatOption) (types.ObjectInfo, error)

	// Delete removes an object
	Delete(ctx context.Context, bucketName, objectName string, opts ...DeleteOption) error

	// List lists objects
	List(ctx context.Context, bucketName string, opts ...ListOption) <-chan types.ObjectInfo

	// ListVersions lists object versions and delete markers
	ListVersions(ctx context.Context, bucketName string, opts ...ListOption) <-chan types.ObjectInfo

	// Copy copies an object
	Copy(ctx context.Context, destBucket, destObject, srcBucket, srcObject string, opts ...CopyOption) (types.CopyInfo, error)

	// Compose creates an object by composing source objects
	Compose(ctx context.Context, dst DestinationInfo, sources []SourceInfo, opts ...PutOption) (types.UploadInfo, error)

	// Append appends data to an object at a specific offset
	Append(ctx context.Context, bucketName, objectName string, reader io.Reader, objectSize int64, offset int64, opts ...PutOption) (types.UploadInfo, error)

	// Select queries object content using S3 Select
	Select(ctx context.Context, bucketName, objectName string, opts s3select.Options) (*s3select.Results, error)

	// Restore initiates a restore request for an archived object
	Restore(ctx context.Context, bucketName, objectName, versionID string, req restore.RestoreRequest) error

	// PresignedPostPolicy creates a presigned POST policy for browser uploads
	PresignedPostPolicy(ctx context.Context, policy *policy.PostPolicy) (*url.URL, map[string]string, error)

	// PresignGet creates a presigned GET URL with optional signed headers
	PresignGet(ctx context.Context, bucketName, objectName string, expires time.Duration, reqParams url.Values, opts ...PresignOption) (*url.URL, http.Header, error)

	// PresignPut creates a presigned PUT URL with optional signed headers
	PresignPut(ctx context.Context, bucketName, objectName string, expires time.Duration, reqParams url.Values, opts ...PresignOption) (*url.URL, http.Header, error)

	// SetTagging sets object tags
	SetTagging(ctx context.Context, bucketName, objectName string, tags map[string]string) error

	// GetTagging retrieves object tags
	GetTagging(ctx context.Context, bucketName, objectName string) (map[string]string, error)

	// DeleteTagging deletes object tags
	DeleteTagging(ctx context.Context, bucketName, objectName string) error

	// GetACL retrieves object ACL
	GetACL(ctx context.Context, bucketName, objectName string) (acl.ACL, error)

	// SetACL sets object ACL
	SetACL(ctx context.Context, bucketName, objectName string, policy acl.ACL) error

	// SetLegalHold sets legal hold status for an object
	SetLegalHold(ctx context.Context, bucketName, objectName string, hold objectlock.LegalHoldStatus, opts ...LegalHoldOption) error

	// GetLegalHold retrieves legal hold status for an object
	GetLegalHold(ctx context.Context, bucketName, objectName string, opts ...LegalHoldOption) (objectlock.LegalHoldStatus, error)

	// SetRetention sets retention mode and retain-until date for an object
	SetRetention(ctx context.Context, bucketName, objectName string, mode objectlock.RetentionMode, retainUntil time.Time, opts ...RetentionOption) error

	// GetRetention retrieves retention configuration for an object
	GetRetention(ctx context.Context, bucketName, objectName string, opts ...RetentionOption) (objectlock.RetentionMode, time.Time, error)
}

Service Object service interface

func NewService

func NewService(executor *core.Executor, locationCache *cache.LocationCache) Service

NewService creates a new Object service

type SourceInfo added in v1.0.5

type SourceInfo struct {
	Bucket string
	Object string

	VersionID string

	RangeStart int64
	RangeEnd   int64
	RangeSet   bool

	MatchETag     string
	NotMatchETag  string
	MatchModified time.Time
	NotModified   time.Time
}

SourceInfo describes a source object for composition.

type StatOption

type StatOption func(*StatOptions)

StatOption applies object info option

type StatOptions

type StatOptions struct {
	// Version ID
	VersionID string

	// Custom headers
	CustomHeaders http.Header
}

StatOptions controls stat/metadata retrieval

Jump to

Keyboard shortcuts

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