Documentation
¶
Index ¶
- Constants
- Variables
- func BucketNotFound(bucket string) error
- func DirSize(path string) (int64, error)
- func ErrorInvalidArgument(name, value, message string) error
- func ErrorMessage(code ErrorCode, message string) error
- func ErrorMessagef(code ErrorCode, message string, args ...interface{}) error
- func GetBetweenStr(str, start, end string) string
- func HasErrorCode(err error, code ErrorCode) bool
- func IsAlreadyExists(err error) bool
- func KeyNotFound(key string) error
- func ListDir(dirPth string) (files []string, files1 []string, err error)
- func ReadAll(r io.Reader, size int64) (b []byte, err error)
- func ResourceError(code ErrorCode, resource string) error
- func Stamp2Str(stamp int64) string
- func Stamp2Time(stamp int64) time.Time
- func Str2Stamp(formatTimeStr string) int64
- func Str2Time(formatTimeStr string) time.Time
- func Time2Stamp() int64
- func Time2Str() string
- func ValidateBucketName(name string) error
- type Backend
- type BucketInfo
- type Buckets
- type CommonPrefix
- type CompleteMultipartUploadRequest
- type CompleteMultipartUploadResult
- type CompletedPart
- type Content
- type ContentTime
- type CopyObjectResult
- type DeleteMarker
- type DeleteRequest
- type Error
- type ErrorCode
- type ErrorInvalidArgumentResponse
- type ErrorResponse
- type ErrorResult
- type GetBucketLocation
- type InitiateMultipartUpload
- type InternalErrorCode
- type ListBucketPage
- type ListBucketResult
- type ListBucketResultBase
- type ListBucketResultV2
- type ListBucketVersionsResult
- type ListMultipartUploadItem
- type ListMultipartUploadPartItem
- type ListMultipartUploadPartsResult
- type ListMultipartUploadsResult
- type LogLevel
- type Logger
- type MFADeleteStatus
- type MultiDeleteResult
- type Object
- type ObjectDeleteResult
- type ObjectID
- type ObjectList
- type ObjectRange
- type ObjectRangeRequest
- type Option
- func WithGlobalLog() Option
- func WithHostBucket(enabled bool) Option
- func WithIntegrityCheck(check bool) Option
- func WithLogger(logger Logger) Option
- func WithMetadataSizeLimit(size int) Option
- func WithRequestID(id uint64) Option
- func WithTimeSkewLimit(skew time.Duration) Option
- func WithTimeSource(timeSource TimeSource) Option
- func WithUnimplementedPageError() Option
- func WithoutVersioning() Option
- type Prefix
- type PrefixMatch
- type PutObjectResult
- type Storage
- type StorageClass
- type TimeSource
- type TimeSourceAdvancer
- type UploadID
- type UploadListMarker
- type UserInfo
- type Version
- type VersionID
- type VersionItem
- type VersionedBackend
- type VersioningConfiguration
- type VersioningStatus
- type Yts3
Constants ¶
View Source
const ( // 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 // 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. // // As this does not specify KB or KiB, KB is used in gofakes3. The reason // for this is if gofakes3 is used for testing, and your tests show that // 2KiB works, but Amazon uses 2KB... that's a much worse time to discover // the disparity! DefaultMetadataSizeLimit = 2000 // Like DefaultMetadataSizeLimit, the docs don't specify MB or MiB, so we // will accept 5MB for now. The Go client SDK rejects 5MB with the error // "part size must be at least 5242880 bytes", which is a hint that it // has been interpreted as MiB at least _somewhere_, but we should remain // liberal in what we accept in the face of ambiguity. DefaultUploadPartSize = 5 * 1000 * 1000 DefaultSkewLimit = 15 * time.Minute MaxUploadsLimit = 1000 DefaultMaxUploads = 1000 MaxUploadPartsLimit = 1000 DefaultMaxUploadParts = 1000 MaxBucketKeys = 1000 DefaultMaxBucketKeys = 1000 MaxBucketVersionKeys = 1000 DefaultMaxBucketVersionKeys = 1000 // From the docs: "Part numbers can be any number from 1 to 10,000, inclusive." MaxUploadPartNumber = 10000 )
View Source
const (
DefaultBucketVersionKeys = 1000
)
View Source
const RangeNoEnd = -1
Variables ¶
View Source
var GetObjectNum *int32 = new(int32)
View Source
var ListBucketNum *int32 = new(int32)
View Source
var RequestNum *int32 = new(int32)
Functions ¶
func BucketNotFound ¶
func ErrorInvalidArgument ¶
func ErrorMessage ¶
func ErrorMessagef ¶
func GetBetweenStr ¶
func HasErrorCode ¶
func IsAlreadyExists ¶
func KeyNotFound ¶
func ResourceError ¶
func ValidateBucketName ¶
Types ¶
type Backend ¶
type Backend interface { ListBuckets(publicKey string) ([]BucketInfo, error) ListBucket(publicKey, name string, prefix *Prefix, page ListBucketPage) (*ObjectList, error) CreateBucket(publicKey, name string) error DeleteMulti(publicKey, bucketName string, objects ...string) (MultiDeleteResult, error) PutObject(publicKey, bucketName, key string, meta map[string]string, input io.Reader, size int64) (PutObjectResult, error) MultipartUpload(publicKey, bucketName, objectName string, partsPath []string, size int64) (PutObjectResult, error) GetObjectV2(publicKey, bucketName, objectName string, rangeRequest *ObjectRangeRequest, prefix *Prefix, page ListBucketPage) (*Object, error) GetObject(publicKey, bucketName, objectName string, rangeRequest *ObjectRangeRequest) (*Object, error) DeleteBucket(publicKey, name string) error HeadObject(publicKey, bucketName, objectName string) (*Object, error) DeleteObject(publicKey, bucketName, objectName string) (ObjectDeleteResult, error) }
type BucketInfo ¶
type BucketInfo struct { Name string `xml:"Name"` // CreationDate is required; without it, boto returns the error "('String // does not contain a date:', ”)" CreationDate ContentTime `xml:"CreationDate"` }
type Buckets ¶
type Buckets []BucketInfo
type CommonPrefix ¶
type CommonPrefix struct {
Prefix string `xml:"Prefix"`
}
type CompleteMultipartUploadRequest ¶
type CompleteMultipartUploadRequest struct {
Parts []CompletedPart `xml:"Part"`
}
type CompletedPart ¶
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,omitempty"` Owner *UserInfo `xml:"Owner,omitempty"` }
type ContentTime ¶
func NewContentTime ¶
func NewContentTime(t time.Time) ContentTime
type CopyObjectResult ¶
type CopyObjectResult struct { XMLName xml.Name `xml:"CopyObjectResult"` ETag string `xml:"ETag,omitempty"` LastModified ContentTime `xml:"LastModified,omitempty"` }
type DeleteMarker ¶
type DeleteRequest ¶
type ErrorCode ¶
type ErrorCode string
const ( ErrNone ErrorCode = "" ErrBadDigest ErrorCode = "BadDigest" ErrInvalidAccessKeyID ErrorCode = "InvalidAccessKeyID" ErrBucketAlreadyExists ErrorCode = "BucketAlreadyExists" ErrBucketNotEmpty ErrorCode = "BucketNotEmpty" ErrIllegalVersioningConfiguration ErrorCode = "IllegalVersioningConfigurationException" ErrIncompleteBody ErrorCode = "IncompleteBody" ErrIncorrectNumberOfFilesInPostRequest ErrorCode = "IncorrectNumberOfFilesInPostRequest" ErrInlineDataTooLarge ErrorCode = "InlineDataTooLarge" ErrInvalidArgument ErrorCode = "InvalidArgument" ErrInvalidBucketName ErrorCode = "InvalidBucketName" ErrInvalidDigest ErrorCode = "InvalidDigest" ErrInvalidRange ErrorCode = "InvalidRange" ErrInvalidToken ErrorCode = "InvalidToken" ErrKeyTooLong ErrorCode = "KeyTooLongError" ErrMalformedPOSTRequest ErrorCode = "MalformedPOSTRequest" ErrInvalidPart ErrorCode = "InvalidPart" ErrInvalidPartOrder ErrorCode = "InvalidPartOrder" ErrInvalidURI ErrorCode = "InvalidURI" ErrMetadataTooLarge ErrorCode = "MetadataTooLarge" ErrMethodNotAllowed ErrorCode = "MethodNotAllowed" ErrMalformedXML ErrorCode = "MalformedXML" ErrMissingContentLength ErrorCode = "MissingContentLength" ErrNoSuchBucket ErrorCode = "NoSuchBucket" ErrNoSuchKey ErrorCode = "NoSuchKey" ErrNoSuchUpload ErrorCode = "NoSuchUpload" ErrNoSuchVersion ErrorCode = "NoSuchVersion" ErrRequestTimeTooSkewed ErrorCode = "RequestTimeTooSkewed" ErrTooManyBuckets ErrorCode = "TooManyBuckets" ErrNotImplemented ErrorCode = "NotImplemented" ErrInternal ErrorCode = "InternalError" ErrAuthorization ErrorCode = "NotAuthorization" )
type ErrorInvalidArgumentResponse ¶
type ErrorInvalidArgumentResponse struct { ErrorResponse ArgumentName string `xml:"ArgumentName"` ArgumentValue string `xml:"ArgumentValue"` }
type ErrorResponse ¶
type ErrorResponse struct { XMLName xml.Name `xml:"Error"` Code ErrorCode Message string `xml:",omitempty"` RequestID string `xml:"RequestId,omitempty"` HostID string `xml:"HostId,omitempty"` }
func (*ErrorResponse) Error ¶
func (e *ErrorResponse) Error() string
func (*ErrorResponse) ErrorCode ¶
func (e *ErrorResponse) ErrorCode() ErrorCode
type ErrorResult ¶
type ErrorResult struct { XMLName xml.Name `xml:"Error"` Key string `xml:"Key,omitempty"` Code ErrorCode `xml:"Code,omitempty"` Message string `xml:"Message,omitempty"` Resource string `xml:"Resource,omitempty"` RequestID string `xml:"RequestId,omitempty"` }
func ErrorResultFromError ¶
func ErrorResultFromError(err error) ErrorResult
func (ErrorResult) String ¶
func (er ErrorResult) String() string
type GetBucketLocation ¶
type InitiateMultipartUpload ¶
type InternalErrorCode ¶
type InternalErrorCode string
const (
ErrInternalPageNotImplemented InternalErrorCode = "PaginationNotImplemented"
)
func (InternalErrorCode) Error ¶
func (e InternalErrorCode) Error() string
func (InternalErrorCode) ErrorCode ¶
func (e InternalErrorCode) ErrorCode() ErrorCode
type ListBucketPage ¶
func (ListBucketPage) IsEmpty ¶
func (p ListBucketPage) IsEmpty() bool
type ListBucketResult ¶
type ListBucketResult struct { ListBucketResultBase Marker string `xml:"Marker"` NextMarker string `xml:"NextMarker,omitempty"` }
type ListBucketResultBase ¶
type ListBucketResultBase struct { XMLName xml.Name `xml:"ListBucketResult"` Xmlns string `xml:"xmlns,attr"` Name string `xml:"Name"` IsTruncated bool `xml:"IsTruncated"` Delimiter string `xml:"Delimiter,omitempty"` Prefix string `xml:"Prefix"` MaxKeys int64 `xml:"MaxKeys,omitempty"` CommonPrefixes []CommonPrefix `xml:"CommonPrefixes,omitempty"` Contents []*Content `xml:"Contents"` }
type ListBucketResultV2 ¶
type ListBucketResultV2 struct { ListBucketResultBase ContinuationToken string `xml:"ContinuationToken,omitempty"` KeyCount int64 `xml:"KeyCount,omitempty"` NextContinuationToken string `xml:"NextContinuationToken,omitempty"` StartAfter string `xml:"StartAfter,omitempty"` }
type ListBucketVersionsResult ¶
type ListBucketVersionsResult struct { XMLName xml.Name `xml:"ListBucketVersionsResult"` Xmlns string `xml:"xmlns,attr"` Name string `xml:"Name"` Delimiter string `xml:"Delimiter,omitempty"` Prefix string `xml:"Prefix,omitempty"` CommonPrefixes []CommonPrefix `xml:"CommonPrefixes,omitempty"` IsTruncated bool `xml:"IsTruncated"` MaxKeys int64 `xml:"MaxKeys"` KeyMarker string `xml:"KeyMarker,omitempty"` NextKeyMarker string `xml:"NextKeyMarker,omitempty"` VersionIDMarker VersionID `xml:"VersionIdMarker,omitempty"` NextVersionIDMarker VersionID `xml:"NextVersionIdMarker,omitempty"` Versions []VersionItem // contains filtered or unexported fields }
type ListMultipartUploadItem ¶
type ListMultipartUploadItem struct { Key string `xml:"Key"` UploadID UploadID `xml:"UploadId"` Initiator *UserInfo `xml:"Initiator,omitempty"` Owner *UserInfo `xml:"Owner,omitempty"` StorageClass StorageClass `xml:"StorageClass,omitempty"` Initiated ContentTime `xml:"Initiated,omitempty"` }
type ListMultipartUploadPartItem ¶
type ListMultipartUploadPartItem struct { PartNumber int `xml:"PartNumber"` LastModified ContentTime `xml:"LastModified,omitempty"` ETag string `xml:"ETag,omitempty"` Size int64 `xml:"Size"` }
type ListMultipartUploadPartsResult ¶
type ListMultipartUploadPartsResult struct { XMLName xml.Name `xml:"ListPartsResult"` Bucket string `xml:"Bucket"` Key string `xml:"Key"` UploadID UploadID `xml:"UploadId"` StorageClass StorageClass `xml:"StorageClass,omitempty"` Initiator *UserInfo `xml:"Initiator,omitempty"` Owner *UserInfo `xml:"Owner,omitempty"` PartNumberMarker int `xml:"PartNumberMarker"` NextPartNumberMarker int `xml:"NextPartNumberMarker"` MaxParts int64 `xml:"MaxParts"` IsTruncated bool `xml:"IsTruncated,omitempty"` Parts []ListMultipartUploadPartItem `xml:"Part"` }
type ListMultipartUploadsResult ¶
type ListMultipartUploadsResult struct { Bucket string `xml:"Bucket"` KeyMarker string `xml:"KeyMarker,omitempty"` UploadIDMarker UploadID `xml:"UploadIdMarker,omitempty"` NextKeyMarker string `xml:"NextKeyMarker,omitempty"` NextUploadIDMarker UploadID `xml:"NextUploadIdMarker,omitempty"` MaxUploads int64 `xml:"MaxUploads,omitempty"` Delimiter string `xml:"Delimiter,omitempty"` Prefix string `xml:"Prefix,omitempty"` CommonPrefixes []CommonPrefix `xml:"CommonPrefixes,omitempty"` IsTruncated bool `xml:"IsTruncated,omitempty"` Uploads []ListMultipartUploadItem `xml:"Upload"` }
type Logger ¶
type Logger interface {
Print(level LogLevel, v ...interface{})
}
type MFADeleteStatus ¶
type MFADeleteStatus string
const ( MFADeleteNone MFADeleteStatus = "" MFADeleteEnabled MFADeleteStatus = "Enabled" MFADeleteDisabled MFADeleteStatus = "Disabled" )
type MultiDeleteResult ¶
type MultiDeleteResult struct { XMLName xml.Name `xml:"DeleteResult"` Deleted []ObjectID `xml:"Deleted"` Error []ErrorResult `xml:",omitempty"` }
type Object ¶
type Object struct { Name string Metadata map[string]string Size int64 Contents io.ReadCloser Hash []byte Range *ObjectRange VersionID VersionID IsDeleteMarker bool }
type ObjectDeleteResult ¶
type ObjectDeleteResult 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 // Returns the version ID of the delete marker created as a result of the // DELETE operation. If you delete a specific object version, the value // returned by this header is the version ID of the object version deleted. VersionID VersionID }
type ObjectList ¶
type ObjectList struct { CommonPrefixes []CommonPrefix Contents []*Content IsTruncated bool NextMarker string // contains filtered or unexported fields }
func NewObjectList ¶
func NewObjectList() *ObjectList
func (*ObjectList) Add ¶
func (b *ObjectList) Add(item *Content)
func (*ObjectList) AddPrefix ¶
func (b *ObjectList) AddPrefix(prefix string)
type ObjectRange ¶
type ObjectRange struct {
Start, Length int64
}
type ObjectRangeRequest ¶
func (*ObjectRangeRequest) Range ¶
func (o *ObjectRangeRequest) Range(size int64) (*ObjectRange, error)
type Option ¶
type Option func(g *Yts3)
func WithGlobalLog ¶
func WithGlobalLog() Option
func WithHostBucket ¶
func WithIntegrityCheck ¶
func WithLogger ¶
func WithMetadataSizeLimit ¶
func WithRequestID ¶
func WithTimeSkewLimit ¶
func WithTimeSource ¶
func WithTimeSource(timeSource TimeSource) Option
func WithUnimplementedPageError ¶
func WithUnimplementedPageError() Option
func WithoutVersioning ¶
func WithoutVersioning() Option
type PrefixMatch ¶
func (*PrefixMatch) AsCommonPrefix ¶
func (match *PrefixMatch) AsCommonPrefix() CommonPrefix
type PutObjectResult ¶
type PutObjectResult struct {
VersionID VersionID
}
type TimeSource ¶
func DefaultTimeSource ¶
func DefaultTimeSource() TimeSource
type TimeSourceAdvancer ¶
type TimeSourceAdvancer interface { TimeSource Advance(by time.Duration) }
func FixedTimeSource ¶
func FixedTimeSource(at time.Time) TimeSourceAdvancer
FixedTimeSource provides a source of time that always returns the specified time.
type UploadListMarker ¶
type Version ¶
type Version struct { XMLName xml.Name `xml:"Version"` Key string `xml:"Key"` VersionID VersionID `xml:"VersionId"` IsLatest bool `xml:"IsLatest"` LastModified ContentTime `xml:"LastModified,omitempty"` Size int64 `xml:"Size"` StorageClass StorageClass `xml:"StorageClass"` ETag string `xml:"ETag"` Owner *UserInfo `xml:"Owner,omitempty"` }
func (Version) GetVersionID ¶
type VersionItem ¶
type VersionItem interface { GetVersionID() VersionID // contains filtered or unexported methods }
type VersionedBackend ¶
type VersionedBackend interface{}
type VersioningConfiguration ¶
type VersioningConfiguration struct { XMLName xml.Name `xml:"VersioningConfiguration"` Status VersioningStatus `xml:"Status"` MFADelete MFADeleteStatus `xml:"MfaDelete"` }
type VersioningStatus ¶
type VersioningStatus string
const ( VersioningNone VersioningStatus = "" VersioningEnabled VersioningStatus = "Enabled" VersioningSuspended VersioningStatus = "Suspended" )
Click to show internal directories.
Click to hide internal directories.