s3

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LifecycleStatusEnabled marks a lifecycle rule as active.
	LifecycleStatusEnabled = "Enabled"
	// LifecycleStatusDisabled marks a lifecycle rule as inactive.
	LifecycleStatusDisabled = "Disabled"
)

Lifecycle rule statuses.

View Source
const (
	// KeySizeLimit defines the maximum size of an S3 object key's name.
	//
	// From https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html:
	// The name for a key is a sequence of Unicode characters whose UTF-8
	// encoding is at most 1024 bytes long.
	KeySizeLimit = 1024

	// MaxUploadPartNumber defines the maximum allowed part number in a multipart
	// upload. AWS allows part numbers between 1 and 10,000 inclusive.
	MaxUploadPartNumber = 10000

	// MinUploadPartSize defines the minimum allowed size for a multipart upload
	// part, except for the last part, which may be smaller.
	MinUploadPartSize int64 = 5 << 20 // 5 MiB

	// MaxUploadPartSize is the maximum allowed size for a single multipart
	// part.
	MaxUploadPartSize int64 = 5 << 30 // 5 GiB

	// MaxUploadListParts defines the maximum number of parts returned in a
	// single ListParts response.
	MaxUploadListParts = 1000

	// DefaultMaxUploadListParts is the default number of parts returned when
	// no limit is specified.
	DefaultMaxUploadListParts = MaxUploadListParts

	// MetadataSizeLimit defines the maximum size of the metadata associated
	// with an S3 object.
	//
	// From https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html:
	// Within the PUT request header, the user-defined metadata is limited to 2
	// KB in size. The size of user-defined metadata is measured by taking the
	// sum of the number of bytes in the UTF-8 encoding of each key and value.
	MetadataSizeLimit = 2000

	// LifecycleRuleIDSizeLimit defines the maximum length of a lifecycle rule
	// ID. AWS allows rule IDs of up to 255 characters.
	LifecycleRuleIDSizeLimit = 255
)
View Source
const (
	// MaxBucketKeys is the maximum number of object keys from a bucket that can
	// be retrieved in one call to ListObjects or deleted by DeleteObjects.
	MaxBucketKeys = 1000

	// DefaultMaxBucketKeys is the default number of object keys from a bucket
	// retrieved by ListObjects if no limit is specified.
	DefaultMaxBucketKeys = 1000

	// MaxMultipartUploads is the maximum number of multipart uploads returned
	// in a single ListMultipartUploads response.
	MaxMultipartUploads = 1000

	// DefaultMaxMultipartUploads is the default number of multipart uploads
	// returned if the client does not specify max-uploads.
	DefaultMaxMultipartUploads = 1000
)
View Source
const (
	// VersioningStatusEnabled means new objects receive unique version IDs and
	// existing versions are retained.
	VersioningStatusEnabled = "Enabled"
	// VersioningStatusSuspended means new objects receive the null version ID while
	// previously created versions are retained.
	VersioningStatusSuspended = "Suspended"
)

Bucket versioning states.

View Source
const Null = "null"

Null is used by S3 to represent an explicit empty value in XML responses. Such as a VersionID or location.

Variables

This section is empty.

Functions

func FormatETag

func FormatETag(hash []byte, partsCount int) string

FormatETag formats the given hash as an S3 ETag string.

func FormatVersion added in v0.1.2

func FormatVersion(versionID string) string

FormatVersion renders an internal version ID for an S3 response. The null version (the empty string) is rendered as the literal "null".

func New

func New(b Backend, opts ...Option) http.Handler

New creates an instance of the S3 API handler using the provided backend.

func NewAdmin

func NewAdmin(b Backend, opts ...Option) http.Handler

NewAdmin creates an HTTP handler that serves the admin API using the provided backend. It exposes /prometheus, which serves the background upload stats as Prometheus metrics, /stats/uploads, which serves the same stats as JSON, /objects/flush, which uploads all pending objects regardless of padding, and /system/sqlite3/backup, which creates a backup of the SQLite3 database.

func ParseETag

func ParseETag(s string) [16]byte

ParseETag attempts to parse the given ETag string into a 16-byte MD5 sum. Returns a zero array if the ETag is empty or invalid.

func ValidateBucketName

func ValidateBucketName(name string) error

ValidateBucketName applies the rules from the AWS docs: https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html#bucketnamingrules

1. Bucket names must comply with DNS naming conventions. 2. Bucket names must be at least 3 and no more than 63 characters long. 3. Bucket names must not contain uppercase characters or underscores. 4. Bucket names must start with a lowercase letter or number.

The DNS RFC confirms that the valid range of characters in an LDH label is 'a-z0-9-': https://tools.ietf.org/html/rfc5890#section-2.3.1

Types

type AbortIncompleteMultipartUpload added in v0.1.2

type AbortIncompleteMultipartUpload struct {
	DaysAfterInitiation int `xml:"DaysAfterInitiation"`
}

AbortIncompleteMultipartUpload describes when incomplete multipart uploads are aborted.

func (*AbortIncompleteMultipartUpload) AbortCutoff added in v0.1.2

func (a *AbortIncompleteMultipartUpload) AbortCutoff(now time.Time, dayDuration time.Duration) time.Time

AbortCutoff returns the cutoff time for aborting incomplete multipart uploads relative to now. Uploads initiated at or before the cutoff are aborted. dayDuration is the wall-clock duration treated as a single "day".

type Backend

type Backend interface {
	auth.KeyStore

	// UserInfo returns user information for the given access key ID.
	UserInfo(ctx context.Context, accessKeyID string) (*UserInfo, error)

	// CopyObject copies an object from the source bucket and object key to the
	// destination bucket and object key. The provided metadata map contains any
	// metadata that should either be merged into the copied object or replace
	// the metadata except for the x-amz-acl header. The replace flag indicates
	// whether the metadata should be replaced (true) or merged (false).
	//
	// - If the source bucket does not exist, [ErrNoSuchBucket] must be returned.
	//
	// - If the source object does not exist, [ErrNoSuchKey] must be returned.
	//
	// - If the destination bucket does not exist, [ErrNoSuchBucket] must be returned.
	//
	// - If the access key does not have permission to read the source object or
	//   write to the destination bucket, [ErrAccessDenied] must be returned.
	//
	// - If the source and destination are the same, the object is kept but its metadata
	//   is merged with the provided metadata.
	//
	// - srcVersion selects the source version: an unspecified request copies the
	//   current version ([ErrNoSuchKey] if it is a delete marker), a specified
	//   request the exact version ("" is the null version, [ErrNoSuchVersion] if
	//   absent).
	CopyObject(ctx context.Context, accessKeyID, srcBucket, srcObject string, srcVersion VersionRequest, dstBucket, dstObject string, replace bool, meta map[string]string) (*CopyObjectResult, error)

	// CreateBucket creates a new bucket with the given name for the user
	// identified by the given access key. Re-creating a bucket the user
	// already owns is idempotent and preserves its contents (matching the AWS
	// default region). If the bucket exists and is owned by another user,
	// [ErrBucketAlreadyExists] must be returned.
	CreateBucket(ctx context.Context, accessKeyID, name string) error

	// DeleteBucket deletes the bucket with the given name for the user
	// identified by the given access key.
	//
	// - If the access key does not have permission to delete the bucket,
	//   [ErrAccessDenied] must be returned.
	//
	// - If the bucket does not exist, [ErrNoSuchBucket] must be returned.
	//
	// - If the bucket is not empty, [ErrBucketNotEmpty] must be returned.
	DeleteBucket(ctx context.Context, accessKeyID, name string) error

	// DeleteObject deletes the object with the given key from the specified
	// bucket for the user identified by the given access key.
	//
	// - If the access key does not have permission to delete the object,
	//   [ErrAccessDenied] must be returned.
	//
	// - If the bucket does not exist, [ErrNoSuchBucket] must be returned.
	//
	DeleteObject(ctx context.Context, accessKeyID, bucket string, object ObjectID) (*DeleteObjectResult, error)

	// DeleteObjects deletes multiple objects from the specified bucket for the
	// user identified by the given access key.
	//
	// - If the access key does not have permission to delete the objects,
	//   [ErrAccessDenied] must be returned.
	//
	// - If the bucket does not exist, [ErrNoSuchBucket] must be returned.
	//
	// - If any of the objects with the given keys in the specified bucket do not
	//   exist, they must still be reported as deleted.
	DeleteObjects(ctx context.Context, accessKeyID, bucket string, objects []ObjectID) (*ObjectsDeleteResult, error)

	// GetObject retrieves the object with the given key from the specified
	// bucket for the user identified by the given access key. The provided
	// range is either nil if no range was requested, or contains the requested,
	// byte range. If partNumber is not nil, the specified part of a multipart
	// upload is retrieved, this can not be combined with a byte range.
	//
	// - If the access key does not have permission to access the object,
	//   [ErrAccessDenied] must be returned. A 'nil' accessKeyID indicates the
	//   anonymous user.
	//
	// - If the bucket does not exist, [ErrNoSuchBucket] must be returned.
	//
	// - If the object with the given key in the specified bucket does not exist,
	//   [ErrNoSuchKey] must be returned.
	//
	// - If the requested range is not satisfiable, [ErrInvalidRange] must be
	//   returned. You can use the 'Range' method on 'rnge' for that.
	//
	// - version unspecified returns the current version ([ErrNoSuchKey] if it is
	//   a delete marker); a specified request returns that exact version ("" is
	//   the null version, [ErrNoSuchVersion] if absent). The result may be a
	//   delete marker (Object.IsDeleteMarker).
	GetObject(ctx context.Context, accessKeyID *string, bucket, object string, version VersionRequest, rnge *ObjectRangeRequest, partNumber *int32) (*Object, error)

	// HeadBucket checks if the bucket with the given name exists and is
	// accessible for the user identified by the given access key.
	//
	// - If the access key does not have permission to access the bucket,
	//   [ErrAccessDenied] must be returned.
	//
	// - If the bucket does not exist, [ErrNoSuchBucket] must be returned.
	HeadBucket(ctx context.Context, accessKeyID, name string) error

	// HeadObject is like GetObject but only retrieves the metadata of the
	// object and returns an empty body.
	HeadObject(ctx context.Context, accessKeyID *string, bucket, object string, version VersionRequest, rnge *ObjectRangeRequest, partNumber *int32) (*Object, error)

	// ListBuckets lists all available buckets for the user identified by the
	// given access key.
	ListBuckets(ctx context.Context, accessKeyID string) ([]BucketInfo, error)

	// ListObjects lists objects in the specified bucket for the user identified
	// by the given access key. The backend should use the prefix to limit the
	// contents of the bucket and sort the results into the Contents and
	// CommonPrefixes fields of the returned ObjectsListResult.
	//
	// - If the access key does not have permission to list objects in the bucket,
	//   [ErrAccessDenied] must be returned.
	//
	// - If the bucket does not exist, [ErrNoSuchBucket] must be returned.
	ListObjects(ctx context.Context, accessKeyID *string, bucket string, prefix Prefix, page ListObjectsPage) (*ObjectsListResult, error)

	// PutObject puts an object with the given key into the specified bucket.
	//
	// - If the access key does not have permission to store the object,
	//   [ErrAccessDenied] must be returned.
	//
	// - If the bucket does not exist, [ErrNoSuchBucket] must be returned.
	//
	// - On a versioning-enabled bucket a new version is created and prior
	//   versions are retained; otherwise (unversioned or suspended) the null
	//   version is overwritten in place.
	//
	// - If the bytes read from 'r' do not match 'contentLength',
	//   [ErrIncompleteBody] must be returned.
	//
	// - If ContentMD5 is set in opts, and the MD5 checksum of the data read
	//   from 'r' does not match, [ErrBadDigest] must be returned.
	PutObject(ctx context.Context, accessKeyID string, bucket, object string, r io.Reader, opts PutObjectOptions) (*PutObjectResult, error)

	// CreateMultipartUpload creates a new multipart upload for the specified
	// key in the specified bucket.
	//
	// - If the access key does not have permission to store the object,
	//   [ErrAccessDenied] must be returned.
	//
	// - If the bucket does not exist, [ErrNoSuchBucket] must be returned.
	CreateMultipartUpload(ctx context.Context, accessKeyID, bucket, object string, opts CreateMultipartUploadOptions) (*CreateMultipartUploadResult, error)

	// ListMultipartUploads lists in-progress multipart uploads for the given
	// bucket.
	//
	// - If the access key does not have permission to list uploads for the
	//   bucket, [ErrAccessDenied] must be returned.
	//
	// - If the bucket does not exist, [ErrNoSuchBucket] must be returned.
	ListMultipartUploads(ctx context.Context, accessKeyID, bucket string, opts ListMultipartUploadsOptions, page ListMultipartUploadsPage) (*ListMultipartUploadsResult, error)

	// AbortMultipartUpload aborts an in-progress multipart upload and
	// discards any uploaded parts.
	//
	// - If the access key does not have permission to write to the object,
	//   [ErrAccessDenied] must be returned.
	//
	// - If the bucket does not exist, [ErrNoSuchBucket] must be returned.
	//
	// - If the multipart upload ID is not known or no longer active,
	//   [ErrNoSuchUpload] must be returned.
	AbortMultipartUpload(ctx context.Context, accessKeyID, bucket, object string, uploadID UploadID) error

	// UploadPart uploads a single part for a previously initiated multipart
	// upload.
	//
	// - If the access key does not have permission to write to the object,
	//   [ErrAccessDenied] must be returned.
	//
	// - If the bucket does not exist, [ErrNoSuchBucket] must be returned.
	//
	// - If the multipart upload ID is not known or no longer active,
	//   [ErrNoSuchUpload] must be returned.
	//
	// - If the bytes read from 'r' do not match 'ContentLength',
	//   [ErrIncompleteBody] must be returned.
	//
	// - If ContentMD5 or ContentSHA256 are set in opts, and the checksums of
	//   the data read from 'r' do not match, [ErrBadDigest] must be returned.
	UploadPart(ctx context.Context, accessKeyID, bucket, object string, uploadID UploadID, r io.Reader, opts UploadPartOptions) (*UploadPartResult, error)

	// UploadPartCopy copies a part from an existing object as part of a
	// multipart upload.
	//
	// - If the access key does not have permission to read the source object or
	//   write to the destination object, [ErrAccessDenied] must be returned.
	//
	// - If either the source or destination bucket does not exist,
	// [ErrNoSuchBucket] must be returned.
	//
	// - If the source object does not exist, [ErrNoSuchKey] must be returned.
	//
	// - srcVersion selects the source version: an unspecified request copies the
	//   current version ([ErrNoSuchKey] if it is a delete marker), a specified
	//   request the exact version ("" is the null version, [ErrNoSuchVersion] if
	//   absent).
	//
	// - If the multipart upload ID is not known or no longer active,
	//   [ErrNoSuchUpload] must be returned.
	UploadPartCopy(ctx context.Context, accessKeyID, srcBucket, srcObject string, srcVersion VersionRequest, dstBucket, dstObject string, uploadID UploadID, opts UploadPartCopyOptions) (*UploadPartCopyResult, error)

	// ListParts lists uploaded parts for the specified multipart upload.
	//
	// - If the access key does not have permission to list parts,
	//   [ErrAccessDenied] must be returned.
	//
	// - If the bucket does not exist, [ErrNoSuchBucket] must be returned.
	//
	// - If the multipart upload ID is not known or no longer active,
	//   [ErrNoSuchUpload] must be returned.
	ListParts(ctx context.Context, accessKeyID, bucket, object string, uploadID UploadID, page ListPartsPage) (*ListPartsResult, error)

	// CompleteMultipartUpload completes a multipart upload by assembling the
	// previously uploaded parts into the final object.
	//
	// - If the access key does not have permission to write to the object,
	//   [ErrAccessDenied] must be returned.
	//
	// - If any referenced part is missing or its ETag does not match,
	//   [ErrInvalidPart] must be returned.
	//
	// - If the part numbers of the parts are not provided in ascending order,
	//   [ErrInvalidPartOrder] must be returned.
	//
	// - If the last part is below the minimum size, [ErrEntityTooSmall] must be returned.
	CompleteMultipartUpload(ctx context.Context, accessKeyID, bucket, object string, uploadID UploadID, parts []CompleteMultipartPart) (*CompleteMultipartUploadResult, error)

	// PutBucketLifecycleConfiguration sets the lifecycle configuration for the
	// specified bucket, replacing any existing configuration.
	//
	// - If the access key does not have permission to configure the bucket,
	//   [ErrAccessDenied] must be returned.
	//
	// - If the bucket does not exist, [ErrNoSuchBucket] must be returned.
	PutBucketLifecycleConfiguration(ctx context.Context, accessKeyID, bucket string, config LifecycleConfiguration) error

	// GetBucketLifecycleConfiguration returns the lifecycle configuration for
	// the specified bucket.
	//
	// - If the access key does not have permission to read the bucket
	//   configuration, [ErrAccessDenied] must be returned.
	//
	// - If the bucket does not exist, [ErrNoSuchBucket] must be returned.
	//
	// - If the bucket has no lifecycle configuration,
	//   [ErrNoSuchLifecycleConfiguration] must be returned.
	GetBucketLifecycleConfiguration(ctx context.Context, accessKeyID, bucket string) (LifecycleConfiguration, error)

	// DeleteBucketLifecycleConfiguration removes the lifecycle configuration
	// for the specified bucket. It is not an error if no configuration exists.
	//
	// - If the access key does not have permission to configure the bucket,
	//   [ErrAccessDenied] must be returned.
	//
	// - If the bucket does not exist, [ErrNoSuchBucket] must be returned.
	DeleteBucketLifecycleConfiguration(ctx context.Context, accessKeyID, bucket string) error

	// PutBucketVersioning sets the versioning state of the specified bucket.
	// status is either "Enabled" or "Suspended".
	//
	// - If the access key does not have permission to configure the bucket,
	//   [ErrAccessDenied] must be returned.
	//
	// - If the bucket does not exist, [ErrNoSuchBucket] must be returned.
	PutBucketVersioning(ctx context.Context, accessKeyID, bucket, status string) error

	// GetBucketVersioning returns the versioning state of the specified
	// bucket. The status is "" if the bucket has never been configured,
	// otherwise "Enabled" or "Suspended".
	//
	// - If the access key does not have permission to read the bucket
	//   configuration, [ErrAccessDenied] must be returned.
	//
	// - If the bucket does not exist, [ErrNoSuchBucket] must be returned.
	GetBucketVersioning(ctx context.Context, accessKeyID, bucket string) (status string, err error)

	// ListObjectVersions lists all versions (including delete markers) of the
	// objects in the specified bucket.
	//
	// - If the access key does not have permission to list the bucket,
	//   [ErrAccessDenied] must be returned.
	//
	// - If the bucket does not exist, [ErrNoSuchBucket] must be returned.
	ListObjectVersions(ctx context.Context, accessKeyID *string, bucket string, prefix Prefix, page ListObjectVersionsPage) (*ObjectVersionsListResult, error)

	// UploadStats returns statistics about the background upload pipeline.
	UploadStats(ctx context.Context) (UploadStats, error)

	// FlushObjects uploads all pending objects to Sia regardless of padding,
	// rather than waiting for the background pipeline to batch them into
	// efficiently packed slabs. It blocks until the uploads complete.
	FlushObjects(ctx context.Context) error

	// BackupSQLite3 creates a backup of the SQLite3 database at the given
	// path on the local filesystem. The backup is a consistent snapshot
	// even if the database is being written to concurrently.
	BackupSQLite3(ctx context.Context, destPath string) error
}

Backend defines the interface for an S3 backend that data uploaded via the S3 API will be stored in.

type BackupSQLite3Request added in v0.1.2

type BackupSQLite3Request struct {
	// Path is the absolute filesystem path where the backup file will be
	// written. It must not already exist.
	Path string `json:"path"`
}

BackupSQLite3Request is the request body for the [POST] /system/sqlite3/backup endpoint.

type BucketInfo

type BucketInfo struct {
	Name         string      `xml:"Name"`
	CreationDate ContentTime `xml:"CreationDate"`
}

BucketInfo represents an S3 bucket

type CommonPrefix

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

CommonPrefix is used in Bucket.CommonPrefixes to list partial delimited keys that represent pseudo-directories.

type CompleteMultipartPart

type CompleteMultipartPart struct {
	PartNumber int    `xml:"PartNumber"`
	ETag       string `xml:"ETag"`
}

CompleteMultipartPart represents a single part in a CompleteMultipartUploadRequest.

type CompleteMultipartUploadRequest

type CompleteMultipartUploadRequest struct {
	XMLName xml.Name                `xml:"CompleteMultipartUpload"`
	Parts   []CompleteMultipartPart `xml:"Part"`
}

CompleteMultipartUploadRequest matches the XML request body sent when completing a multipart upload.

type CompleteMultipartUploadResponse

type CompleteMultipartUploadResponse struct {
	XMLName  xml.Name `xml:"CompleteMultipartUploadResult"`
	Xmlns    string   `xml:"xmlns,attr"`
	Location string   `xml:"Location"`
	Bucket   string   `xml:"Bucket"`
	Key      string   `xml:"Key"`
	ETag     string   `xml:"ETag"`
}

CompleteMultipartUploadResponse matches the XML response returned after a successful CompleteMultipartUpload operation.

type CompleteMultipartUploadResult

type CompleteMultipartUploadResult struct {
	ETag       string
	ContentMD5 [16]byte
	// VersionID is the wire-encoded version to report to the client, or "" on a
	// suspended or unversioned bucket (no header emitted).
	VersionID string
}

CompleteMultipartUploadResult contains metadata about the completed object, such as the final ETag.

type CompletedPart

type CompletedPart struct {
	PartNumber int
	ETag       [16]byte
}

CompletedPart represents a single part referenced during a multipart completion request.

type Content

type Content struct {
	Key          string       `xml:"Key"`
	LastModified ContentTime  `xml:"LastModified"`
	ETag         string       `xml:"ETag"`
	Size         int64        `xml:"Size"`
	StorageClass StorageClass `xml:"StorageClass"`
	Owner        *UserInfo    `xml:"Owner,omitempty"`
}

Content represents an S3 object in a bucket listing.

type ContentTime

type ContentTime struct {
	time.Time
}

ContentTime is a wrapper around time.Time to provide custom XML marshalling.

func NewContentTime

func NewContentTime(t time.Time) ContentTime

NewContentTime creates a new ContentTime instance.

func (ContentTime) MarshalXML

func (c ContentTime) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML implements custom XML marshalling for ContentTime.

type CopyObjectResult

type CopyObjectResult struct {
	ContentMD5   [16]byte
	LastModified time.Time
	// VersionID is the wire-encoded version of the new copy ("" on a suspended
	// or unversioned bucket, neither of which reports a version).
	VersionID string
	// SourceVersionID is the wire-encoded version copied, reported when the
	// source bucket is versioned (Enabled or Suspended), else "".
	SourceVersionID string
	PartsCount      int32
}

CopyObjectResult contains information about the result of a CopyObject operation.

type CreateMultipartUploadOptions

type CreateMultipartUploadOptions struct {
	Meta map[string]string
}

CreateMultipartUploadOptions contains options for initiating a multipart upload.

type CreateMultipartUploadResult

type CreateMultipartUploadResult struct {
	UploadID UploadID
}

CreateMultipartUploadResult returns an upload ID for a newly created multipart upload. This ID is used to identify the multipart upload in subsequent requests.

type DeleteMarker added in v0.1.2

type DeleteMarker struct {
	XMLName      xml.Name    `xml:"DeleteMarker"`
	Key          string      `xml:"Key"`
	VersionID    string      `xml:"VersionId"`
	IsLatest     bool        `xml:"IsLatest"`
	LastModified ContentTime `xml:"LastModified,omitempty"`
	Owner        *UserInfo   `xml:"Owner,omitempty"`
}

DeleteMarker represents a delete marker in a ListObjectVersions response.

type DeleteObjectResult

type DeleteObjectResult struct {
	// Specifies whether the versioned object that was permanently deleted was
	// (true) or was not (false) a delete marker. In a simple DELETE, this
	// header indicates whether (true) or not (false) a delete marker was
	// created.
	IsDeleteMarker bool

	// VersionID is the wire-encoded version affected by the delete, or "" when
	// no version applies (unversioned bucket).
	VersionID string
}

DeleteObjectResult contains information about the result of a DeleteObject operation.

type DeleteRequest

type DeleteRequest struct {
	Objects []ObjectID `xml:"Object"`

	// Quiet is used to enable quiet mode for the request.
	//
	// By default, the operation uses verbose mode in which the response
	// includes the result of deletion of each key in your request. In quiet
	// mode the response includes only keys where the delete operation
	// encountered an error. For a successful deletion, the operation does not
	// return any information about the delete in the response body.
	Quiet bool `xml:"Quiet"`
}

DeleteRequest represents a multi delete request.

type DeletedObject added in v0.1.2

type DeletedObject struct {
	Key       string `xml:"Key"`
	VersionID string `xml:"VersionId,omitempty"`
	// DeleteMarker is true when the delete created a delete marker or the
	// deleted version was itself a delete marker.
	DeleteMarker bool `xml:"DeleteMarker,omitempty"`
	// DeleteMarkerVersionID is the version ID of the delete marker created
	// or removed by the delete.
	DeleteMarkerVersionID string `xml:"DeleteMarkerVersionId,omitempty"`
}

DeletedObject describes a single successfully deleted object in a multi delete response.

type ErrorResponse

type ErrorResponse struct {
	XMLName xml.Name `xml:"Error"`

	Code      string `xml:"Code"`
	Message   string `xml:"Message,omitempty"`
	RequestID string `xml:"RequestId,omitempty"`
	HostID    string `xml:"HostId,omitempty"`
}

ErrorResponse is the standard XML error response returned by S3.

type ErrorResult

type ErrorResult struct {
	XMLName   xml.Name `xml:"Error"`
	Key       string   `xml:"Key,omitempty"`
	Code      string   `xml:"Code,omitempty"`
	Message   string   `xml:"Message,omitempty"`
	Resource  string   `xml:"Resource,omitempty"`
	RequestID string   `xml:"RequestId,omitempty"`
}

ErrorResult represents an error encountered while deleting an object during a multi delete operation.

type GetBucketLocation

type GetBucketLocation struct {
	XMLName            xml.Name `xml:"LocationConstraint"`
	Xmlns              string   `xml:"xmlns,attr"`
	LocationConstraint string   `xml:",chardata"`
}

GetBucketLocation is the response to a GetBucketLocation request.

type HttpTime

type HttpTime struct {
	time.Time
}

HttpTime is a wrapper around time.Time to provide custom XML marshalling.

func NewHttpTime

func NewHttpTime(t time.Time) HttpTime

NewHttpTime creates a new HttpTime instance.

func (HttpTime) MarshalXML

func (c HttpTime) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML implements custom XML marshalling for HttpTime.

func (*HttpTime) StdTime

func (c *HttpTime) StdTime() time.Time

StdTime returns the standard time.Time value.

func (*HttpTime) UnmarshalXML

func (c *HttpTime) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements custom XML unmarshalling for HttpTime.

type InitiateMultipartUploadResponse

type InitiateMultipartUploadResponse struct {
	XMLName  xml.Name `xml:"InitiateMultipartUploadResult"`
	Xmlns    string   `xml:"xmlns,attr"`
	Bucket   string   `xml:"Bucket"`
	Key      string   `xml:"Key"`
	UploadID string   `xml:"UploadId"`
}

InitiateMultipartUploadResponse matches the XML response returned by AWS when creating a multipart upload.

type LifecycleAndOperator added in v0.1.2

type LifecycleAndOperator struct {
	Prefix                *string        `xml:"Prefix,omitempty"`
	Tags                  []LifecycleTag `xml:"Tag"`
	ObjectSizeGreaterThan *int64         `xml:"ObjectSizeGreaterThan,omitempty"`
	ObjectSizeLessThan    *int64         `xml:"ObjectSizeLessThan,omitempty"`
}

LifecycleAndOperator combines multiple filter predicates.

type LifecycleConfiguration added in v0.1.2

type LifecycleConfiguration struct {
	XMLName xml.Name `xml:"LifecycleConfiguration"`
	// Xmlns is omitempty, unlike other messages, because the configuration
	// is also marshaled for persistence, where the namespace attribute is
	// left out.
	Xmlns string          `xml:"xmlns,attr,omitempty"`
	Rules []LifecycleRule `xml:"Rule"`
}

LifecycleConfiguration is the S3 bucket lifecycle configuration document.

https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketLifecycleConfiguration.html

func (LifecycleConfiguration) ExpirationHeader added in v0.1.2

func (c LifecycleConfiguration) ExpirationHeader(objectKey string, lastModified time.Time) string

ExpirationHeader returns the x-amz-expiration response header value for an object with the given key and last-modified time, or "" if no enabled expiration rule applies. When several rules match, the soonest expiration wins.

func (LifecycleConfiguration) Validate added in v0.1.2

func (c LifecycleConfiguration) Validate() error

Validate checks that the lifecycle configuration is well-formed and only uses features supported by this server.

type LifecycleExpiration added in v0.1.2

type LifecycleExpiration struct {
	Days                      int    `xml:"Days,omitempty"`
	Date                      string `xml:"Date,omitempty"`
	ExpiredObjectDeleteMarker *bool  `xml:"ExpiredObjectDeleteMarker,omitempty"`
}

LifecycleExpiration describes when current object versions expire.

func (*LifecycleExpiration) ExpiryCutoff added in v0.1.2

func (e *LifecycleExpiration) ExpiryCutoff(now time.Time, dayDuration time.Duration) (cutoff time.Time, ok bool)

ExpiryCutoff returns the cutoff time for current-version expiration relative to now. Objects last modified at or before the cutoff are expired. ok is false when the expiration is not currently active (e.g. a future Date, or a rule that only references ExpiredObjectDeleteMarker, which is unsupported without versioning). dayDuration is the wall-clock duration treated as a single "day" when evaluating a Days window.

type LifecycleFilter added in v0.1.2

type LifecycleFilter struct {
	Prefix                *string               `xml:"Prefix,omitempty"`
	Tag                   *LifecycleTag         `xml:"Tag,omitempty"`
	And                   *LifecycleAndOperator `xml:"And,omitempty"`
	ObjectSizeGreaterThan *int64                `xml:"ObjectSizeGreaterThan,omitempty"`
	ObjectSizeLessThan    *int64                `xml:"ObjectSizeLessThan,omitempty"`
}

LifecycleFilter restricts the objects a rule applies to.

type LifecycleRule added in v0.1.2

type LifecycleRule struct {
	ID     string `xml:"ID,omitempty"`
	Status string `xml:"Status"`
	// Prefix is the deprecated rule-level prefix. Newer clients use Filter
	// instead. At most one of Prefix and Filter may be set.
	Prefix                         *string                         `xml:"Prefix,omitempty"`
	Filter                         *LifecycleFilter                `xml:"Filter,omitempty"`
	Expiration                     *LifecycleExpiration            `xml:"Expiration,omitempty"`
	AbortIncompleteMultipartUpload *AbortIncompleteMultipartUpload `xml:"AbortIncompleteMultipartUpload,omitempty"`
	// The remaining actions are parsed only so they can be rejected during
	// validation; dropping an action a client asked for would misrepresent
	// the stored configuration.
	Transitions                  []LifecycleUnsupportedAction `xml:"Transition,omitempty"`
	NoncurrentVersionTransitions []LifecycleUnsupportedAction `xml:"NoncurrentVersionTransition,omitempty"`
	NoncurrentVersionExpiration  *LifecycleUnsupportedAction  `xml:"NoncurrentVersionExpiration,omitempty"`
}

LifecycleRule is a single lifecycle rule.

func (LifecycleRule) EffectivePrefix added in v0.1.2

func (r LifecycleRule) EffectivePrefix() string

EffectivePrefix returns the object key prefix the rule applies to, drawn from either the deprecated rule-level prefix or the filter.

func (LifecycleRule) Enabled added in v0.1.2

func (r LifecycleRule) Enabled() bool

Enabled reports whether the rule is enabled.

type LifecycleTag added in v0.1.2

type LifecycleTag struct {
	Key   string `xml:"Key"`
	Value string `xml:"Value"`
}

LifecycleTag is an object tag used in a lifecycle filter.

type LifecycleUnsupportedAction added in v0.1.2

type LifecycleUnsupportedAction struct{}

LifecycleUnsupportedAction marks the presence of a lifecycle action this server does not support. Its contents are not modeled; presence alone causes validation to fail.

type ListBucketsResponse

type ListBucketsResponse struct {
	XMLName xml.Name     `xml:"ListAllMyBucketsResult"`
	Xmlns   string       `xml:"xmlns,attr"`
	Owner   *UserInfo    `xml:"Owner,omitempty"`
	Buckets []BucketInfo `xml:"Buckets>Bucket"`
}

ListBucketsResponse is the response to a ListBuckets request

type ListMultipartUploadsOptions

type ListMultipartUploadsOptions struct {
	Prefix    string
	Delimiter string
}

ListMultipartUploadsOptions contains options for listing in-progress multipart uploads for a bucket.

type ListMultipartUploadsPage

type ListMultipartUploadsPage struct {
	// KeyMarker specifies the key in the bucket that represents the last item
	// in the previous page. The first key in the returned page will be the next
	// lexicographically (UTF-8 binary) sorted key after KeyMarker.
	KeyMarker string

	// UploadIDMarker specifies the upload ID of the last upload in the previous
	// page when multiple uploads exist for the same key. Only used when KeyMarker
	// is also specified.
	UploadIDMarker string

	// MaxUploads sets the maximum number of uploads returned in the response.
	// The response might contain fewer uploads, but will never contain more.
	MaxUploads int64
}

ListMultipartUploadsPage contains pagination parameters for listing multipart uploads.

type ListMultipartUploadsResponse

type ListMultipartUploadsResponse struct {
	XMLName            xml.Name                `xml:"ListMultipartUploadsResult"`
	Xmlns              string                  `xml:"xmlns,attr"`
	Bucket             string                  `xml:"Bucket"`
	KeyMarker          string                  `xml:"KeyMarker,omitempty"`
	UploadIDMarker     string                  `xml:"UploadIdMarker,omitempty"`
	NextKeyMarker      string                  `xml:"NextKeyMarker,omitempty"`
	NextUploadIDMarker string                  `xml:"NextUploadIdMarker,omitempty"`
	MaxUploads         int64                   `xml:"MaxUploads"`
	IsTruncated        bool                    `xml:"IsTruncated"`
	Prefix             string                  `xml:"Prefix,omitempty"`
	Delimiter          string                  `xml:"Delimiter,omitempty"`
	CommonPrefixes     []CommonPrefix          `xml:"CommonPrefixes,omitempty"`
	Uploads            []ListedMultipartUpload `xml:"Upload"`
}

ListMultipartUploadsResponse is the response to a ListMultipartUploads request.

type ListMultipartUploadsResult

type ListMultipartUploadsResult struct {
	Uploads            []MultipartUploadInfo
	CommonPrefixes     []string
	IsTruncated        bool
	NextKeyMarker      string
	NextUploadIDMarker string
}

ListMultipartUploadsResult contains the uploads returned by the backend along with pagination metadata.

type ListObjectVersionsPage added in v0.1.2

type ListObjectVersionsPage struct {
	// FetchOwner specifies whether owner information should be included.
	FetchOwner *bool

	// KeyMarker is the key to resume listing after, or nil to start from the
	// beginning.
	KeyMarker *string

	// VersionIDMarker is the wire-encoded version to resume within KeyMarker, or
	// nil for all of KeyMarker's versions. The wire value "null" represents the
	// null version.
	VersionIDMarker *string

	// MaxKeys sets the maximum number of versions returned in the response.
	MaxKeys int64
}

ListObjectVersionsPage specifies pagination options for listing object versions in a bucket.

type ListObjectVersionsResult

type ListObjectVersionsResult struct {
	XMLName xml.Name `xml:"ListVersionsResult"`
	ListObjectsResultBase

	KeyMarker       string `xml:"KeyMarker"`
	VersionIDMarker string `xml:"VersionIdMarker"`

	// When the number of responses exceeds the value of MaxKeys, NextKeyMarker
	// specifies the first key not returned that satisfies the search criteria.
	// Use this value for the key-marker request parameter in a subsequent
	// request.
	NextKeyMarker string `xml:"NextKeyMarker,omitempty"`

	// When the number of responses exceeds the value of MaxKeys,
	// NextVersionIdMarker specifies the first object version not returned that
	// satisfies the search criteria. Use this value for the version-id-marker
	// request parameter in a subsequent request.
	NextVersionIDMarker string `xml:"NextVersionIdMarker,omitempty"`

	// Versions holds the Version and DeleteMarker elements interleaved in
	// response order: key ascending, then newest version first.
	Versions []VersionListEntry
}

ListObjectVersionsResult is the response to a ListObjectVersions request.

type ListObjectsPage

type ListObjectsPage struct {
	// FetchOwner specifies whether owner information should be included in
	// the response. If nil or false, the Owner field of returned objects will
	// be nil. If true, the Owner field of returned objects will be set.
	FetchOwner *bool

	// Marker specifies the key in the bucket that represents the last item in
	// the previous page. The first key in the returned page will be the next
	// lexicographically (UTF-8 binary) sorted key after Marker. If HasMarker is
	// true, this must be non-empty.
	Marker *string

	// MaxKeys sets the maximum number of keys returned in the response body.
	// The response might contain fewer keys, but will never contain more. If
	// additional keys satisfy the search criteria, but were not returned
	// because max-keys was exceeded, the response contains
	// <isTruncated>true</isTruncated>. To return the additional keys, see
	// key-marker and version-id-marker.
	//
	MaxKeys int64
}

ListObjectsPage specifies pagination options for listing objects in a bucket.

type ListObjectsResultBase

type ListObjectsResultBase struct {
	Xmlns string `xml:"xmlns,attr"`

	// Name of the bucket.
	Name string `xml:"Name"`

	// Specifies whether (true) or not (false) all of the results were
	// returned. If the number of results exceeds that specified by MaxKeys,
	// all of the results might not be returned.
	IsTruncated bool `xml:"IsTruncated"`

	// Causes keys that contain the same string between the prefix and the
	// first occurrence of the delimiter to be rolled up into a single result
	// element in the CommonPrefixes collection. These rolled-up keys are not
	// returned elsewhere in the response.
	//
	// NOTE: Each rolled-up result in CommonPrefixes counts as only one return
	// against the MaxKeys value.
	Delimiter string `xml:"Delimiter,omitempty"`

	Prefix string `xml:"Prefix"`

	MaxKeys int64 `xml:"MaxKeys,omitempty"`

	EncodingType string `xml:"EncodingType,omitempty"`

	CommonPrefixes []CommonPrefix `xml:"CommonPrefixes,omitempty"`
	Contents       []*Content     `xml:"Contents"`
}

ListObjectsResultBase is the common part of a listing response. The concrete result types declare their own XMLName so they can be marshalled under the correct root element.

type ListObjectsV1Result

type ListObjectsV1Result struct {
	XMLName xml.Name `xml:"ListBucketResult"`
	ListObjectsResultBase

	// Indicates where in the bucket listing begins. Echoed from the
	// request.
	Marker string `xml:"Marker"`

	// When the response is truncated, you can use the key name in this
	// field as the marker in the subsequent request to get the next set
	// of objects.
	NextMarker string `xml:"NextMarker,omitempty"`
}

ListObjectsV1Result is the response to a ListObjects (v1) request.

type ListObjectsV2Result

type ListObjectsV2Result struct {
	XMLName xml.Name `xml:"ListBucketResult"`
	ListObjectsResultBase

	// If ContinuationToken was sent with the request, it is included in the
	// response.
	ContinuationToken *string `xml:"ContinuationToken,omitempty"`

	// Returns the number of keys included in the response. The value is always
	// less than or equal to the MaxKeys value.
	KeyCount int64 `xml:"KeyCount,omitempty"`

	// If the response is truncated, Amazon S3 returns this parameter with a
	// continuation token. You can specify the token as the continuation-token
	// in your next request to retrieve the next set of keys.
	NextContinuationToken string `xml:"NextContinuationToken,omitempty"`

	// If StartAfter was sent with the request, it is included in the response.
	StartAfter string `xml:"StartAfter,omitempty"`
}

ListObjectsV2Result is the response to a ListObjectsV2 request.

type ListPartsPage

type ListPartsPage struct {
	PartNumberMarker int
	MaxParts         int64
}

ListPartsPage specifies pagination options when listing the parts of an in-progress multipart upload.

type ListPartsResponse

type ListPartsResponse struct {
	XMLName              xml.Name             `xml:"ListPartsResult"`
	Xmlns                string               `xml:"xmlns,attr"`
	Bucket               string               `xml:"Bucket"`
	Key                  string               `xml:"Key"`
	UploadID             string               `xml:"UploadId"`
	PartNumberMarker     int                  `xml:"PartNumberMarker"`
	NextPartNumberMarker int                  `xml:"NextPartNumberMarker,omitempty"`
	MaxParts             int64                `xml:"MaxParts"`
	IsTruncated          bool                 `xml:"IsTruncated"`
	StorageClass         StorageClass         `xml:"StorageClass"`
	Initiator            *UserInfo            `xml:"Initiator,omitempty"`
	Owner                *UserInfo            `xml:"Owner,omitempty"`
	Parts                []ListedPartResponse `xml:"Part"`
}

ListPartsResponse matches the XML response returned by AWS when listing uploaded parts for an in-progress multipart upload.

type ListPartsResult

type ListPartsResult struct {
	Parts                []UploadPart
	IsTruncated          bool
	NextPartNumberMarker string
	OwnerID              string
	OwnerDisplayName     string
	StorageClass         StorageClass
	InitiatorID          string
	InitiatorDisplayName string
}

ListPartsResult contains metadata about uploaded parts.

type ListedMultipartUpload

type ListedMultipartUpload struct {
	Key          string       `xml:"Key"`
	UploadID     string       `xml:"UploadId"`
	Initiator    *UserInfo    `xml:"Initiator,omitempty"`
	Owner        *UserInfo    `xml:"Owner,omitempty"`
	StorageClass StorageClass `xml:"StorageClass"`
	Initiated    ContentTime  `xml:"Initiated"`
}

ListedMultipartUpload represents a single multipart upload in a listing.

type ListedPartResponse

type ListedPartResponse struct {
	PartNumber   int         `xml:"PartNumber"`
	LastModified ContentTime `xml:"LastModified,omitempty"`
	ETag         string      `xml:"ETag"`
	Size         int64       `xml:"Size"`
}

ListedPartResponse represents a single part entry in a ListParts response.

type MultipartUploadInfo

type MultipartUploadInfo struct {
	Key       string
	UploadID  UploadID
	Initiated time.Time
}

MultipartUploadInfo represents a single multipart upload in a listing.

type Object

type Object struct {
	Body         io.ReadCloser
	ContentMD5   [16]byte
	LastModified time.Time
	Metadata     map[string]string
	Range        *ObjectRange
	Size         int64

	// VersionID is the version ID of the object, or "" for the null version.
	VersionID string

	// Versioned reports whether the object's bucket has versioning
	// configured (Enabled or Suspended). When false, no version header is
	// emitted.
	Versioned bool

	// IsDeleteMarker is true when the requested version is a delete marker.
	IsDeleteMarker bool

	// PartsCount will be set for objects that are multipart uploads, but only
	// if a multipart part number is specified.
	PartsCount *int32
}

Object represents an S3 object stored on the backend.

type ObjectCopyResult

type ObjectCopyResult struct {
	XMLName      xml.Name    `xml:"CopyObjectResult"`
	ETag         string      `xml:"ETag"`
	LastModified ContentTime `xml:"LastModified,omitempty"`
}

ObjectCopyResult contains the response from a CopyObject operation.

type ObjectID

type ObjectID struct {
	Key string `xml:"Key"`

	ETag             *string   `xml:"ETag,omitempty"`
	Size             *int64    `xml:"Size,omitempty"`
	LastModifiedTime *HttpTime `xml:"LastModifiedTime,omitempty"`

	// VersionID addresses a specific version ("" is the null version), or nil
	// when no version was specified.
	// nolint:tagliatelle
	VersionID *string `xml:"VersionId,omitempty"`
}

ObjectID represents an object to be deleted in a multi-delete request.

type ObjectRange

type ObjectRange struct {
	Start, Length int64
}

ObjectRange specifies a byte range within an object. The backend can derive this from a ObjectRangeRequest using the size of the object.

type ObjectRangeRequest

type ObjectRangeRequest struct {
	Start, End int64
	FromEnd    bool
}

ObjectRangeRequest specifies a requested byte range within an object. Clients provide this since they don't necessarily know the size of an object.

func (*ObjectRangeRequest) Range

func (o *ObjectRangeRequest) Range(size int64) (*ObjectRange, error)

Range computes the actual byte range to retrieve based on the ObjectRangeRequest and the total size of the object.

type ObjectVersion added in v0.1.2

type ObjectVersion struct {
	Key            string
	VersionID      string // "" represents the null version
	IsLatest       bool
	IsDeleteMarker bool
	LastModified   time.Time
	ETag           string // empty for delete markers
	Size           int64
	Owner          *UserInfo
}

ObjectVersion is a single version (or delete marker) of an object, as returned by ListObjectVersions.

type ObjectVersionsListResult added in v0.1.2

type ObjectVersionsListResult struct {
	CommonPrefixes []CommonPrefix
	Versions       []ObjectVersion
	IsTruncated    bool
	NextKeyMarker  string
	// NextVersionIDMarker is wire-encoded: "null" for the null version, "" when
	// the truncation boundary is a common prefix (no version applies).
	NextVersionIDMarker string
	// contains filtered or unexported fields
}

ObjectVersionsListResult contains the result of a ListObjectVersions operation. Versions are ordered by key ascending, then by version creation order descending (newest first), with delete markers interleaved.

func NewObjectVersionsListResult added in v0.1.2

func NewObjectVersionsListResult(maxKeys int64) *ObjectVersionsListResult

NewObjectVersionsListResult creates a new, empty ObjectVersionsListResult. Use AddVersion and AddPrefix to populate it.

func (*ObjectVersionsListResult) AddPrefix added in v0.1.2

func (r *ObjectVersionsListResult) AddPrefix(prefix string)

AddPrefix rolls a key up under a common prefix (deduping repeats), or marks the result truncated if the page is already full.

func (*ObjectVersionsListResult) AddVersion added in v0.1.2

func (r *ObjectVersionsListResult) AddVersion(v ObjectVersion)

AddVersion appends a version (or delete marker), or marks the result truncated if the page is already full.

func (*ObjectVersionsListResult) Count added in v0.1.2

func (r *ObjectVersionsListResult) Count() int64

Count returns the number of versions and common prefixes added so far.

type ObjectsDeleteResult

type ObjectsDeleteResult struct {
	XMLName xml.Name        `xml:"DeleteResult"`
	Deleted []DeletedObject `xml:"Deleted"`
	Error   []ErrorResult   `xml:",omitempty"`
}

ObjectsDeleteResult contains the response from a multi delete operation.

type ObjectsListResult

type ObjectsListResult struct {
	CommonPrefixes []CommonPrefix
	Contents       []*Content
	IsTruncated    bool
	NextMarker     string
	// contains filtered or unexported fields
}

ObjectsListResult contains the result of a ListObjects operation.

func NewObjectsListResult

func NewObjectsListResult(maxKeys int64) *ObjectsListResult

NewObjectsListResult creates a new, empty ObjectsListResult. Use Add and AddPrefix to populate it.

func (*ObjectsListResult) Add

func (b *ObjectsListResult) Add(item *Content)

Add adds an object to the result.

func (*ObjectsListResult) AddPrefix

func (b *ObjectsListResult) AddPrefix(prefix string)

AddPrefix adds a common prefix to the result. If the prefix has already been added, this is a no-op.

type Option

type Option func(*s3)

Option is a configuration option for the S3 API handler.

func WithHostBucketBases

func WithHostBucketBases(bases []string) Option

WithHostBucketBases sets the host bucket bases for the S3 API handler. e.g. if you run the handler on "s3.example.com", you would set the base to "s3.example.com" to make sure that requests to "mybucket.s3.example.com" are routed to the "mybucket" bucket. "localhost" is always included as a base, so virtual-hosted-style requests work out of the box on local setups.

func WithLogger

func WithLogger(logger *zap.Logger) Option

WithLogger sets the logger for the S3 API handler.

func WithRegion

func WithRegion(region string) Option

WithRegion sets the AWS region for the S3 API handler. If empty, all regions are allowed during authentication. If set, only requests signed for the given region will be accepted.

type PartCopyResult

type PartCopyResult struct {
	XMLName      xml.Name    `xml:"CopyPartResult"`
	ETag         string      `xml:"ETag"`
	LastModified ContentTime `xml:"LastModified,omitempty"`
}

PartCopyResult contains the response from an UploadPartCopy operation.

type Prefix

type Prefix struct {
	HasPrefix bool
	Prefix    string

	HasDelimiter bool
	Delimiter    string
}

Prefix represents an optional prefix and delimiter for listing objects in a bucket.

func (Prefix) CommonPrefix

func (p Prefix) CommonPrefix(key string) string

CommonPrefix computes the common prefix for the given key based on this prefix's delimiter. Returns an empty string if the key doesn't match the prefix or if no delimiter is set.

type PutObjectOptions

type PutObjectOptions struct {
	Meta          map[string]string
	ContentLength int64
	ContentMD5    *[16]byte
	ContentSHA256 *[32]byte
}

PutObjectOptions contains options for a PutObject operation.

ContentMD5 and ContentSHA256 are optional checksums of the object data. If set, the backend needs to validate the data against the provided checksums and return an error if they don't match.

type PutObjectResult

type PutObjectResult struct {
	// ContentMD5 is the MD5 checksum of the object data.
	ContentMD5 [16]byte

	// VersionID is the wire-encoded version to report, or "" on a suspended or
	// unversioned bucket.
	VersionID string
}

PutObjectResult contains information about the result of a PutObject operation.

type StorageClass

type StorageClass string

StorageClass represents the storage class of an S3 object. If not specified, it defaults to "STANDARD".

func (StorageClass) MarshalXML

func (s StorageClass) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML implements custom XML marshalling for StorageClass to override the empty value.

type UploadID

type UploadID [16]byte

UploadID is a unique identifier for a multipart upload.

func NewUploadID

func NewUploadID() (uid UploadID)

NewUploadID generates a new random upload ID.

func ParseUploadID

func ParseUploadID(s string) (UploadID, error)

ParseUploadID parses an upload ID from its hexadecimal string representation.

func (UploadID) String

func (uid UploadID) String() string

String returns the hexadecimal string representation of the upload ID.

type UploadPart

type UploadPart struct {
	PartNumber   int
	LastModified time.Time
	Size         int64
	ContentMD5   [16]byte
}

UploadPart represents a single uploaded part that can be returned by ListParts.

type UploadPartCopyOptions

type UploadPartCopyOptions struct {
	PartNumber int
	Range      ObjectRange
}

UploadPartCopyOptions contains options for copying an individual part in a multipart upload.

type UploadPartCopyResult

type UploadPartCopyResult struct {
	ContentMD5   [16]byte
	LastModified time.Time
	// SourceVersionID is the wire-encoded version that was copied ("" when the
	// source bucket is unversioned, so no header is emitted).
	SourceVersionID string
}

UploadPartCopyResult contains metadata about a copied part, such as the computed MD5 checksum and the object's last modification time.

type UploadPartOptions

type UploadPartOptions struct {
	PartNumber    int
	ContentLength int64
	ContentMD5    *[16]byte
	ContentSHA256 *[32]byte
}

UploadPartOptions contains options for uploading an individual part in a multipart upload.

type UploadPartResult

type UploadPartResult struct {
	ContentMD5   [16]byte
	LastModified time.Time
}

UploadPartResult contains metadata about an uploaded part, such as the computed MD5 checksum.

type UploadStats

type UploadStats struct {
	PendingObjects   int64 `json:"pendingObjects"`
	PendingSize      int64 `json:"pendingSize"`
	UploadedObjects  int64 `json:"uploadedObjects"`
	UploadedSize     int64 `json:"uploadedSize"`
	UnpinnedObjects  int64 `json:"unpinnedObjects"`
	FailedUploads    int64 `json:"failedUploads"`
	OrphanedObjects  int64 `json:"orphanedObjects"`
	MultipartUploads int64 `json:"multipartUploads"`
}

UploadStats contains statistics about the background upload pipeline.

func (UploadStats) PrometheusMetric

func (s UploadStats) PrometheusMetric() []prometheus.Metric

PrometheusMetric implements the prometheus.Marshaller interface for the upload stats response.

type UserInfo

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

UserInfo represents the owner of a resource

type Version

type Version struct {
	XMLName      xml.Name    `xml:"Version"`
	Key          string      `xml:"Key"`
	VersionID    string      `xml:"VersionId"`
	IsLatest     bool        `xml:"IsLatest"`
	LastModified ContentTime `xml:"LastModified,omitempty"`
	Size         int64       `xml:"Size"`

	// According to the S3 docs, this is always STANDARD for a Version:
	StorageClass StorageClass `xml:"StorageClass"`

	ETag  string    `xml:"ETag"`
	Owner *UserInfo `xml:"Owner,omitempty"`
}

Version represents a version of an S3 object in a ListObjectVersions response.

type VersionListEntry added in v0.1.2

type VersionListEntry interface {
	// contains filtered or unexported methods
}

VersionListEntry is a Version or DeleteMarker. They share one slice so their interleaved order is preserved; xml emits each under its own XMLName.

type VersionRequest added in v0.1.2

type VersionRequest struct {
	// Specified reports whether the request addressed a particular version. When
	// false the operation targets the current version.
	Specified bool
	// ID is the internal version ID when Specified is true; "" is the null
	// version.
	ID string
}

VersionRequest identifies which version of an object an operation addresses. It distinguishes "no version was specified" (target the current version) from "the null version was specified", a distinction a raw version string cannot make.

func NoVersion added in v0.1.2

func NoVersion() VersionRequest

NoVersion returns a VersionRequest addressing the current version.

func SpecificVersion added in v0.1.2

func SpecificVersion(id string) VersionRequest

SpecificVersion returns a VersionRequest addressing the given internal version ID ("" is the null version).

func VersionFromQuery added in v0.1.2

func VersionFromQuery(qv []string) VersionRequest

VersionFromQuery resolves the ?versionId= subresource into a VersionRequest. An absent or empty value addresses the current version; the wire value "null" (sent by Boto) addresses the null version, represented internally as "".

func (VersionRequest) LogValue added in v0.1.2

func (v VersionRequest) LogValue() string

LogValue renders the requested version for logging: empty when no version was specified, otherwise the wire encoding.

type VersioningConfiguration added in v0.1.2

type VersioningConfiguration struct {
	XMLName xml.Name `xml:"VersioningConfiguration"`
	Xmlns   string   `xml:"xmlns,attr,omitempty"`
	// Status is the versioning state of the bucket: "Enabled" or
	// "Suspended". It is omitted when the bucket has never been configured.
	Status string `xml:"Status,omitempty"`
	// MfaDelete reflects the MFA delete state. MFA delete is not supported,
	// so this is only parsed to reject attempts to enable it.
	MfaDelete string `xml:"MfaDelete,omitempty"`
}

VersioningConfiguration is the S3 bucket versioning configuration document used by PutBucketVersioning and GetBucketVersioning.

https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketVersioning.html

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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