object

package
v1.0.6 Latest Latest
Warning

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

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

Documentation

Overview

Package object object/acl.go

Package object object/append.go

Package object object/checksum.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/multipart_list.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 WithAccelerate added in v1.0.6

func WithAccelerate() interface{}

WithAccelerate enables S3 Accelerate for compatible object operations.

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 WithCopyAccelerate added in v1.0.6

func WithCopyAccelerate() CopyOption

WithCopyAccelerate enables S3 Accelerate for Copy operations.

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

	// Use S3 Accelerate endpoint
	UseAccelerate bool
}

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 WithGetAccelerate added in v1.0.6

func WithGetAccelerate() GetOption

WithGetAccelerate enables S3 Accelerate for Get operations.

func WithGetCSE added in v1.0.6

func WithGetCSE(client *cse.Client) GetOption

WithGetCSE enables client-side decryption for downloads.

func WithGetRange

func WithGetRange(start, end int64) GetOption

WithGetRange sets byte range for downloads

func WithGetResponseHeaders added in v1.0.6

func WithGetResponseHeaders(values url.Values) GetOption

WithGetResponseHeaders sets response header override query parameters.

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

	// Response header overrides (query params like response-content-type)
	ResponseHeaderOverrides url.Values

	// Use S3 Accelerate endpoint
	UseAccelerate bool

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

	// Client-side encryption helper
	CSE *cse.Client

	// 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 ListMultipartUploadsOptions added in v1.0.6

type ListMultipartUploadsOptions struct {
	Prefix         string
	Delimiter      string
	KeyMarker      string
	UploadIDMarker string
	MaxUploads     int
}

ListMultipartUploadsOptions controls multipart upload listing.

type ListMultipartUploadsResult added in v1.0.6

type ListMultipartUploadsResult struct {
	XMLName            xml.Name          `xml:"ListMultipartUploadsResult"`
	Bucket             string            `xml:"Bucket"`
	KeyMarker          string            `xml:"KeyMarker"`
	UploadIDMarker     string            `xml:"UploadIdMarker"`
	NextKeyMarker      string            `xml:"NextKeyMarker"`
	NextUploadIDMarker string            `xml:"NextUploadIdMarker"`
	MaxUploads         int               `xml:"MaxUploads"`
	IsTruncated        bool              `xml:"IsTruncated"`
	Uploads            []MultipartUpload `xml:"Upload"`
	CommonPrefixes     []CommonPrefix    `xml:"CommonPrefixes"`
}

ListMultipartUploadsResult represents ListMultipartUploads 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

	// Use S3 Accelerate endpoint
	UseAccelerate bool
}

ListOptions controls object listing

type ListPartsOption added in v1.0.6

type ListPartsOption func(*ListPartsOptions)

ListPartsOption applies list parts options

func WithListPartsMarker added in v1.0.6

func WithListPartsMarker(marker int) ListPartsOption

WithListPartsMarker sets the part number marker for pagination.

func WithListPartsMax added in v1.0.6

func WithListPartsMax(max int) ListPartsOption

WithListPartsMax sets the maximum parts to return.

type ListPartsOptions added in v1.0.6

type ListPartsOptions struct {
	PartNumberMarker int
	MaxParts         int
}

ListPartsOptions controls list parts behavior.

type ListPartsResult added in v1.0.6

type ListPartsResult struct {
	XMLName              xml.Name           `xml:"ListPartsResult"`
	Bucket               string             `xml:"Bucket"`
	Key                  string             `xml:"Key"`
	UploadID             string             `xml:"UploadId"`
	PartNumberMarker     int                `xml:"PartNumberMarker"`
	NextPartNumberMarker int                `xml:"NextPartNumberMarker"`
	MaxParts             int                `xml:"MaxParts"`
	IsTruncated          bool               `xml:"IsTruncated"`
	Initiator            UserIdentity       `xml:"Initiator"`
	Owner                UserIdentity       `xml:"Owner"`
	StorageClass         string             `xml:"StorageClass"`
	Parts                []types.ObjectPart `xml:"Part"`
}

ListPartsResult represents ListParts response.

type MultipartListOption added in v1.0.6

type MultipartListOption func(*ListMultipartUploadsOptions)

MultipartListOption applies multipart upload listing options

func WithMultipartDelimiter added in v1.0.6

func WithMultipartDelimiter(delimiter string) MultipartListOption

WithMultipartDelimiter sets the delimiter for multipart listing.

func WithMultipartKeyMarker added in v1.0.6

func WithMultipartKeyMarker(marker string) MultipartListOption

WithMultipartKeyMarker sets the key marker for pagination.

func WithMultipartMaxUploads added in v1.0.6

func WithMultipartMaxUploads(max int) MultipartListOption

WithMultipartMaxUploads sets the maximum uploads to return.

func WithMultipartPrefix added in v1.0.6

func WithMultipartPrefix(prefix string) MultipartListOption

WithMultipartPrefix filters multipart uploads by prefix.

func WithMultipartUploadIDMarker added in v1.0.6

func WithMultipartUploadIDMarker(marker string) MultipartListOption

WithMultipartUploadIDMarker sets the upload ID marker for pagination.

type MultipartUpload added in v1.0.6

type MultipartUpload struct {
	Key          string       `xml:"Key"`
	UploadID     string       `xml:"UploadId"`
	Initiator    UserIdentity `xml:"Initiator"`
	Owner        UserIdentity `xml:"Owner"`
	StorageClass string       `xml:"StorageClass"`
	Initiated    string       `xml:"Initiated"`
}

MultipartUpload represents a multipart upload entry.

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 WithChecksumAlgorithm added in v1.0.6

func WithChecksumAlgorithm(algorithm string) PutOption

WithChecksumAlgorithm sets the checksum algorithm (e.g., CRC32C).

func WithChecksumMode added in v1.0.6

func WithChecksumMode(mode string) PutOption

WithChecksumMode sets checksum mode (e.g., ENABLED).

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 WithPutAccelerate added in v1.0.6

func WithPutAccelerate() PutOption

WithPutAccelerate enables S3 Accelerate for Put/Multipart operations.

func WithPutCSE added in v1.0.6

func WithPutCSE(client *cse.Client) PutOption

WithPutCSE enables client-side encryption for uploads.

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

	// Checksum mode and algorithm
	ChecksumMode      string
	ChecksumAlgorithm string

	// Custom headers
	CustomHeaders http.Header

	// Whether to send Content-MD5
	SendContentMD5 bool

	// Disable Content-SHA256
	DisableContentSHA256 bool

	// Server-side encryption
	SSE sse.Encrypter

	// Client-side encryption helper
	CSE *cse.Client

	// 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

	// Use S3 Accelerate endpoint
	UseAccelerate bool
	// 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)

	// PresignHead creates a presigned HEAD URL with optional signed headers
	PresignHead(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)

	// ListMultipartUploads lists in-progress multipart uploads for a bucket
	ListMultipartUploads(ctx context.Context, bucketName string, opts ...MultipartListOption) (ListMultipartUploadsResult, error)

	// ListObjectParts lists parts for a specific multipart upload
	ListObjectParts(ctx context.Context, bucketName, objectName, uploadID string, opts ...ListPartsOption) (ListPartsResult, 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

func WithStatAccelerate added in v1.0.6

func WithStatAccelerate() StatOption

WithStatAccelerate enables S3 Accelerate for Stat operations.

type StatOptions

type StatOptions struct {
	// Version ID
	VersionID string

	// Custom headers
	CustomHeaders http.Header

	// Use S3 Accelerate endpoint
	UseAccelerate bool
}

StatOptions controls stat/metadata retrieval

type UserIdentity added in v1.0.6

type UserIdentity struct {
	ID          string `xml:"ID"`
	DisplayName string `xml:"DisplayName"`
}

UserIdentity represents an owner/initiator in multipart listing.

Jump to

Keyboard shortcuts

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