tos

package
v2.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 2 more Imports: 36 Imported by: 14

Documentation

Index

Constants

View Source
const (
	MaxPartSize = 5 * 1024 * 1024 * 1024
	MinPartSize = 5 * 1024 * 1024
)
View Source
const (
	// Deprecated: use enum.ACLPrivate instead
	ACLPrivate = "private"
	// Deprecated: use enum.ACLPublicRead instead
	ACLPublicRead = "public-read"
	// Deprecated: use enum.ACLPublicReadWrite instead
	ACLPublicReadWrite = "public-read-write"
	// Deprecated: use enum.ACLAuthRead instead
	ACLAuthRead = "authenticated-read"
	// Deprecated: use enum.ACLBucketOwnerRead instead
	ACLBucketOwnerRead = "bucket-owner-read"
	// Deprecated: use enum.ACLBucketOwnerFullControl instead
	ACLBucketOwnerFullControl = "bucket-owner-full-control"
	// Deprecated: use enum.ACLLogDeliveryWrite instead
	ACLLogDeliveryWrite = "log-delivery-write"

	// Deprecated: use enum.PermissionRead instead
	PermissionRead = "READ"
	// Deprecated: use enum.PermissionWrite instead
	PermissionTypeWrite = "WRITE"
	// Deprecated: use enum.PermissionReadAcp instead
	PermissionTypeReadAcp = "READ_ACP"
	// Deprecated: use enum.PermissionWriteAcp instead
	PermissionTypeWriteAcp = "WRITE_ACP"
	// Deprecated: use enum.PermissionFullControl instead
	PermissionFullControl = "FULL_CONTROL"
)
View Source
const (
	// MetadataDirectiveReplace replace source object metadata when calling CopyObject
	MetadataDirectiveReplace = "REPLACE"

	// MetadataDirectiveCopy copy source object metadata when calling CopyObject
	MetadataDirectiveCopy = "COPY"
)
View Source
const (
	HeaderUserAgent                   = "User-Agent"
	HeaderContentLength               = "Content-Length"
	HeaderContentType                 = "Content-Type"
	HeaderContentMD5                  = "Content-MD5"
	HeaderContentSha256               = "X-Tos-Content-Sha256"
	HeaderContentLanguage             = "Content-Language"
	HeaderContentEncoding             = "Content-Encoding"
	HeaderContentDisposition          = "Content-Disposition"
	HeaderLastModified                = "Last-Modified"
	HeaderCacheControl                = "Cache-Control"
	HeaderExpires                     = "Expires"
	HeaderETag                        = "ETag"
	HeaderVersionID                   = "X-Tos-Version-Id"
	HeaderDeleteMarker                = "X-Tos-Delete-Marker"
	HeaderStorageClass                = "X-Tos-Storage-Class"
	HeaderAzRedundancy                = "X-Tos-Az-Redundancy"
	HeaderRestore                     = "X-Tos-Restore"
	HeaderTag                         = "X-Tos-Tag"
	HeaderSSECustomerAlgorithm        = "X-Tos-Server-Side-Encryption-Customer-Algorithm"
	HeaderSSECustomerKeyMD5           = "X-Tos-Server-Side-Encryption-Customer-Key-MD5"
	HeaderSSECustomerKey              = "X-Tos-Server-Side-Encryption-Customer-Key"
	HeaderServerSideEncryption        = "X-Tos-Server-Side-Encryption"
	HeaderCopySourceSSECAlgorithm     = "X-Tos-Server-Side-Encryption-Customer-Algorithm"
	HeaderCopySourceSSECKeyMD5        = "X-Tos-Server-Side-Encryption-Customer-Key-MD5"
	HeaderCopySourceSSECKey           = "X-Tos-Server-Side-Encryption-Customer-Key"
	HeaderIfModifiedSince             = "If-Modified-Since"
	HeaderIfUnmodifiedSince           = "If-Unmodified-Since"
	HeaderIfMatch                     = "If-Match"
	HeaderIfNoneMatch                 = "If-None-Match"
	HeaderRange                       = "Range"
	HeaderContentRange                = "Content-Range"
	HeaderRequestID                   = "X-Tos-Request-Id"
	HeaderID2                         = "X-Tos-Id-2"
	HeaderBucketRegion                = "X-Tos-Bucket-Region"
	HeaderLocation                    = "Location"
	HeaderACL                         = "X-Tos-Acl"
	HeaderGrantFullControl            = "X-Tos-Grant-Full-Control"
	HeaderGrantRead                   = "X-Tos-Grant-Read"
	HeaderGrantReadAcp                = "X-Tos-Grant-Read-Acp"
	HeaderGrantWrite                  = "X-Tos-Grant-Write"
	HeaderGrantWriteAcp               = "X-Tos-Grant-Write-Acp"
	HeaderNextAppendOffset            = "X-Tos-Next-Append-Offset"
	HeaderObjectType                  = "X-Tos-Object-Type"
	HeaderHashCrc64ecma               = "X-Tos-Hash-Crc64ecma"
	HeaderMetadataDirective           = "X-Tos-Metadata-Directive"
	HeaderCopySource                  = "X-Tos-Copy-Source"
	HeaderCopySourceIfMatch           = "X-Tos-Copy-Source-If-Match"
	HeaderCopySourceIfNoneMatch       = "X-Tos-Copy-Source-If-None-Match"
	HeaderCopySourceIfModifiedSince   = "X-Tos-Copy-Source-If-Modified-Since"
	HeaderCopySourceIfUnmodifiedSince = "X-Tos-Copy-Source-If-Unmodified-Since"
	HeaderCopySourceRange             = "X-Tos-Copy-Source-Range"
	HeaderCopySourceVersionID         = "X-Tos-Copy-Source-Version-Id"
	HeaderWebsiteRedirectLocation     = "X-Tos-Website-Redirect-Location"
	HeaderCSType                      = "X-Tos-Cs-Type"
	HeaderMetaPrefix                  = "X-Tos-Meta-"
)
View Source
const (
	DefaultCacheCap = 100
	VolceHostSuffix = "volces.com"
	HostSplitSep    = "."
	HostSplitLength = 4
)
View Source
const (
	FetchTaskStateFailed  = "Failed"
	FetchTaskStateSucceed = "Succeed"
	FetchTaskStateExpired = "Expired"
	FetchTaskStateRunning = "Running"
)
View Source
const (
	NoRetry retryAction = iota
	Retry
)
View Source
const (
	EventPartSucceed = 3
	EventPartFailed  = 4
	EventPartAborted = 5 // The task needs to be interrupted in case of 403, 404, 405 errors
)
View Source
const (
	BucketVersioningEnable    = "Enabled"
	BucketVersioningSuspended = "Suspended"
)
View Source
const DefaultFilePerm = os.FileMode(0644)
View Source
const DefaultProgressCallbackSize = 512 * 1024
View Source
const (
	DefaultRetryBackoffBase = 100 * time.Millisecond
)
View Source
const DefaultTaskBufferSize = 100
View Source
const (
	ISO8601TimeFormat = "2006-01-02T15:04:05.000Z07:00"
)
View Source
const (
	QueryPartNumber = "partNumber"
)
View Source
const TempFileSuffix = ".temp"
View Source
const (
	// Version tos-go-sdk version
	Version = "v2.3.3"
)

Variables

View Source
var (
	InputIsNilClientError             = newTosClientError("input is nil. ", nil)
	InputInvalidClientError           = newTosClientError("input data is invalid. ", nil)
	InvalidBucketNameLength           = newTosClientError("invalid bucket name, the length must be [3, 63]", nil)
	InvalidBucketNameCharacter        = newTosClientError("invalid bucket name, the character set is illegal", nil)
	InvalidBucketNameStartingOrEnding = newTosClientError("invalid bucket name, the bucket name can be neither starting with '-' nor ending with '-'", nil)
	InvalidObjectNameLength           = newTosClientError("invalid object name, the length must be [1, 696]", nil)
	InvalidObjectNameStartingOrEnding = newTosClientError("invalid object name, the object name can not start with '\\'", nil)
	InvalidObjectNameCharacterSet     = newTosClientError("invalid object name, the character set is illegal", nil)
	InvalidACL                        = newTosClientError("invalid acl type", nil)
	InvalidStorageClass               = newTosClientError("invalid storage class", nil)
	InvalidGrantee                    = newTosClientError("invalid grantee type", nil)
	InvalidCanned                     = newTosClientError("invalid canned type", nil)
	InvalidAzRedundancy               = newTosClientError("invalid az redundancy type", nil)
	InvalidMetadataDirective          = newTosClientError("invalid metadata directive type", nil)
	InvalidPermission                 = newTosClientError("invalid permission type", nil)
	InvalidSSECAlgorithm              = newTosClientError("invalid encryption-decryption algorithm", nil)
	InvalidPartSize                   = newTosClientError("invalid part size, the size must be [5242880, 5368709120]", nil)
	InvalidSrcFilePath                = newTosClientError("invalid file path, the file does not exist", nil)
	InvalidFilePartNum                = newTosClientError("unsupported part number, the maximum is 10000", nil)
	InvalidMarshal                    = newTosClientError("unable to do serialization/deserialization", nil)
	InvalidPreSignedURLExpires        = newTosClientError("invalid pre signed url expires, the time must be less 604800 seconds.", nil)
)
View Source
var DefaultCrcTable = func() *crc64.Table {
	return crc64.MakeTable(crc64.ECMA)
}
View Source
var (
	ErrETagMissMatch = errors.New("tos: ETag miss match")
)

Functions

func CRC64Combine

func CRC64Combine(crc1 uint64, crc2 uint64, len2 uint64) uint64

CRC64Combine combines CRC64

func Code

func Code(err error) string

Code return error code saved in TosServerError

func GetUnixTimeMs added in v2.2.0

func GetUnixTimeMs() int64

func Int64

func Int64(value int64) *int64

func IsValidBucketName

func IsValidBucketName(name string) error

IsValidBucketName validate bucket name, return TosClientError if failed

func NewCRC

func NewCRC(tab *crc64.Table, init uint64) hash.Hash64

NewCRC is similar with crc64.New, but you can set the initial value. Following methods are copied from package crc64 to implement Hash interface.

func RequestID

func RequestID(err error) string

func SigningKey

func SigningKey(info *SigningKeyInfo) []byte

func StatueCode deprecated

func StatueCode(err error) int

StatueCode return status code saved in TosServerError or UnexpectedStatusCodeError

Deprecated: use StatusCode instead

func StatusCode

func StatusCode(err error) int

StatusCode return status code saved in TosServerError or UnexpectedStatusCodeError

func StringPtr added in v2.2.0

func StringPtr(input string) *string

func SupportedRegion

func SupportedRegion() map[string]string

func ToMillis added in v2.2.0

func ToMillis(t time.Time) int64

func URIEncode

func URIEncode(in string, encodeSlash bool) []byte

func UTCNow

func UTCNow() time.Time

Types

type AbortMultipartUploadInput

type AbortMultipartUploadInput struct {
	// Bucket is needed in V2 api
	Bucket   string
	Key      string
	UploadID string `location:"query" locationName:"uploadId"`
}

type AbortMultipartUploadOutput

type AbortMultipartUploadOutput struct {
	RequestInfo `json:"-"`
}

type AppendObjectOutput

type AppendObjectOutput struct {
	RequestInfo      `json:"-"`
	ETag             string `json:"ETag,omitempty"`
	NextAppendOffset int64  `json:"NextAppendOffset,omitempty"`
}

type AppendObjectV2Input

type AppendObjectV2Input struct {
	Bucket             string
	Key                string
	Offset             int64 `location:"query" locationName:"offset" default:"0"`
	Content            io.Reader
	ContentLength      int64        `location:"header" locationName:"Content-Length"`
	ContentMD5         string       `location:"header" locationName:"Content-MD5"`
	ContentSHA256      string       `location:"header" locationName:"X-Tos-Content-Sha256"`
	CacheControl       string       `location:"header" locationName:"Cache-Control"`
	ContentDisposition string       `location:"header" locationName:"Content-Disposition" encodeChinese:"true"`
	ContentEncoding    string       `location:"header" locationName:"Content-Encoding"`
	ContentLanguage    string       `location:"header" locationName:"Content-Language"`
	ContentType        string       `location:"header" locationName:"Content-Type"`
	Expires            time.Time    `location:"header" locationName:"Expires"`
	ACL                enum.ACLType `location:"header" locationName:"X-Tos-Acl"`

	GrantFullControl string `location:"header" locationName:"X-Tos-Grant-Full-Control"` // optional
	GrantRead        string `location:"header" locationName:"X-Tos-Grant-Read"`         // optional
	GrantReadAcp     string `location:"header" locationName:"X-Tos-Grant-Read-Acp"`     // optional
	GrantWriteAcp    string `location:"header" locationName:"X-Tos-Grant-Write-Acp"`    // optional

	WebsiteRedirectLocation string                `location:"header" locationName:"X-Tos-Website-Redirect-Location"`
	StorageClass            enum.StorageClassType `location:"header" locationName:"X-Tos-Storage-Class"`

	Meta                 map[string]string `location:"headers"`
	DataTransferListener DataTransferListener
	RateLimiter          RateLimiter
	PreHashCrc64ecma     uint64
}

type AppendObjectV2Output

type AppendObjectV2Output struct {
	RequestInfo      `json:"-"`
	VersionID        string `json:"VersionID,omitempty"`
	NextAppendOffset int64  `json:"NextAppendOffset,omitempty"`
	HashCrc64ecma    uint64 `json:"HashCrc64Ecma,omitempty"`
}

type Bucket

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

func (*Bucket) AbortMultipartUpload deprecated

func (bkt *Bucket) AbortMultipartUpload(ctx context.Context, input *AbortMultipartUploadInput, options ...Option) (*AbortMultipartUploadOutput, error)

AbortMultipartUpload abort a multipart upload operation

Deprecated: use AbortMultipartUpload of ClientV2 instead

func (*Bucket) AppendObject deprecated

func (bkt *Bucket) AppendObject(ctx context.Context, objectKey string, content io.Reader, offset int64, options ...Option) (*AppendObjectOutput, error)

AppendObject append content at the tail of an appendable object

objectKey: the name of object
content: the content of object
offset: append position, equals to the current object-size
options: WithContentType set Content-Type,
  WithContentDisposition set Content-Disposition,
  WithContentLanguage set Content-Language,
  WithContentEncoding set Content-Encoding,
  WithCacheControl set Cache-Control,
  WithExpires set Expires,
  WithMeta set meta header(s),
  WithACL WithACLGrantFullControl WithACLGrantRead WithACLGrantReadAcp WithACLGrantWrite WithACLGrantWriteAcp set object acl
above options only take effect when offset parameter is 0.
  WithContentSHA256 set Content-Sha256,
  WithContentMD5 set Content-MD5.

NOTICE: only content with a known length is supported now,

e.g, bytes.Buffer, bytes.Reader, strings.Reader, os.File, io.LimitedReader, net.Buffers.
if the parameter content(an io.Reader) is not one of these,
please use io.LimitReader(reader, length) to wrap this reader or use the WithContentLength option.

Deprecated: use AppendObject of ClientV2 instead

func (*Bucket) CompleteMultipartUpload deprecated

func (bkt *Bucket) CompleteMultipartUpload(ctx context.Context, input *CompleteMultipartUploadInput, options ...Option) (*CompleteMultipartUploadOutput, error)

CompleteMultipartUpload complete a multipart upload operation

input: input.Key the object name,
  input.UploadID the uploadID got from CreateMultipartUpload
  input.UploadedParts upload part output got from UploadPart or UploadPartCopy

Deprecated: use CompleteMultipartUpload of ClientV2 instead

func (*Bucket) CopyObject deprecated

func (bkt *Bucket) CopyObject(ctx context.Context, srcObjectKey, dstObjectKey string, options ...Option) (*CopyObjectOutput, error)

CopyObject copy an object

srcObjectKey: the source object name
dstObjectKey: the destination object name. srcObjectKey and dstObjectKey belongs to the same bucket.
options: WithVersionID the version id of source object,
  WithMetadataDirective copy source object metadata or replace with new object metadata,
  WithACL WithACLGrantFullControl WithACLGrantRead WithACLGrantReadAcp WithACLGrantWrite WithACLGrantWriteAcp set object acl,
  WithCopySourceIfMatch WithCopySourceIfNoneMatch WithCopySourceIfModifiedSince WithCopySourceIfUnmodifiedSince set copy conditions
if CopyObject called with WithMetadataDirective(tos.MetadataDirectiveReplace), these options can be used:
  WithContentType set Content-Type,
  WithContentDisposition set Content-Disposition,
  WithContentLanguage set Content-Language,
  WithContentEncoding set Content-Encoding,
  WithCacheControl set Cache-Control,
  WithExpires set Expires,
  WithMeta set meta header(s),

Deprecated: use CopyObject of ClientV2 instead

func (*Bucket) CopyObjectFrom deprecated

func (bkt *Bucket) CopyObjectFrom(ctx context.Context, srcBucket, srcObjectKey, dstObjectKey string, options ...Option) (*CopyObjectOutput, error)

CopyObjectFrom copy an object from target bucket

srcBucket: the srcBucket bucket
srcObjectKey: the source object name
dstObjectKey: the destination object name
options: WithVersionID the version id of source object,
  WithMetadataDirective copy source object metadata or replace with new object metadata
  WithACL WithACLGrantFullControl WithACLGrantRead WithACLGrantReadAcp WithACLGrantWrite WithACLGrantWriteAcp set object acl,
  WithCopySourceIfMatch WithCopySourceIfNoneMatch WithCopySourceIfModifiedSince WithCopySourceIfUnmodifiedSince set copy conditions
if CopyObjectFrom called with WithMetadataDirective(tos.MetadataDirectiveReplace), these options can be used:
  WithContentType set Content-Type,
  WithContentDisposition set Content-Disposition,
  WithContentLanguage set Content-Language,
  WithContentEncoding set Content-Encoding,
  WithCacheControl set Cache-Control,
  WithExpires set Expires,
  WithMeta set meta header(s),

Deprecated: use CopyObject of ClientV2 instead

func (*Bucket) CopyObjectTo deprecated

func (bkt *Bucket) CopyObjectTo(ctx context.Context, dstBucket, dstObjectKey, srcObjectKey string, options ...Option) (*CopyObjectOutput, error)

CopyObjectTo copy an object to target bucket

dstBucket: the destination bucket
dstObjectKey: the destination object name
srcObjectKey: the source object name
options: WithVersionID the version id of source object,
  WithMetadataDirective copy source object metadata or replace with new object metadata.
  WithACL WithACLGrantFullControl WithACLGrantRead WithACLGrantReadAcp WithACLGrantWrite WithACLGrantWriteAcp set object acl,
  WithCopySourceIfMatch WithCopySourceIfNoneMatch WithCopySourceIfModifiedSince WithCopySourceIfUnmodifiedSince set copy conditions
if CopyObjectTo called with WithMetadataDirective(tos.MetadataDirectiveReplace), these options can be used:
  WithContentType set Content-Type,
  WithContentDisposition set Content-Disposition,
  WithContentLanguage set Content-Language,
  WithContentEncoding set Content-Encoding,
  WithCacheControl set Cache-Control,
  WithExpires set Expires,
  WithMeta set meta header(s),

Deprecated: use CopyObject of ClientV2 instead

func (*Bucket) CreateMultipartUpload deprecated

func (bkt *Bucket) CreateMultipartUpload(ctx context.Context, objectKey string, options ...Option) (*CreateMultipartUploadOutput, error)

CreateMultipartUpload create a multipart upload operation

objectKey: the name of object
options: WithContentType set Content-Type,
  WithContentDisposition set Content-Disposition,
  WithContentLanguage set Content-Language,
  WithContentEncoding set Content-Encoding,
  WithCacheControl set Cache-Control,
  WithExpires set Expires,
  WithMeta set meta header(s),
  WithContentSHA256 set Content-Sha256,
  WithContentMD5 set Content-MD5
  WithExpires set Expires,
  WithServerSideEncryptionCustomer set server side encryption options
  WithACL WithACLGrantFullControl WithACLGrantRead WithACLGrantReadAcp WithACLGrantWrite WithACLGrantWriteAcp set object acl

Deprecated: use CreateMultipartUpload of ClientV2 instead

func (*Bucket) DeleteMultiObjects deprecated

func (bkt *Bucket) DeleteMultiObjects(ctx context.Context, input *DeleteMultiObjectsInput, options ...Option) (*DeleteMultiObjectsOutput, error)

DeleteMultiObjects delete multi-objects

input: the objects will be deleted

Deprecated: use DeleteMultiObjects of ClientV2 instead

func (*Bucket) DeleteObject deprecated

func (bkt *Bucket) DeleteObject(ctx context.Context, objectKey string, options ...Option) (*DeleteObjectOutput, error)

DeleteObject delete an object

objectKey: the name of object
options: WithVersionID which version of this object will be deleted

Deprecated: use DeleteObject of ClientV2 instead

func (*Bucket) FetchObject

func (bkt *Bucket) FetchObject(ctx context.Context, input *FetchObjectInput, options ...Option) (*FetchObjectOutput, error)

FetchObject fetch an object from specified URL options:

WithMeta set meta header(s)
WithServerSideEncryptionCustomer set server side encryption options
WithACL WithACLGrantFullControl WithACLGrantRead WithACLGrantReadAcp WithACLGrantWrite WithACLGrantWriteAcp set object acl

Calling FetchObject will be blocked util fetch operation is finished

func (*Bucket) GetFetchTask added in v2.1.8

func (bkt *Bucket) GetFetchTask(ctx context.Context, input *GetFetchTaskInput, options ...Option) (*GetFetchTaskOutput, error)

GetFetchTask query the task state by the TaskID Task state:

FetchTaskStateFailed  = "Failed"
FetchTaskStateSucceed = "Succeed"
FetchTaskStateExpired = "Expired"
FetchTaskStateRunning = "Running"

func (*Bucket) GetObject deprecated

func (bkt *Bucket) GetObject(ctx context.Context, objectKey string, options ...Option) (*GetObjectOutput, error)

GetObject get data and metadata of an object

objectKey: the name of object
options: WithVersionID which version of this object
  WithRange the range of content,
  WithIfModifiedSince return if the object modified after the given date, otherwise return status code 304
  WithIfUnmodifiedSince, WithIfMatch, WithIfNoneMatch set If-Unmodified-Since, If-Match and If-None-Match

Deprecated: use GetObject of ClientV2 instead

func (*Bucket) GetObjectAcl deprecated

func (bkt *Bucket) GetObjectAcl(ctx context.Context, objectKey string, options ...Option) (*GetObjectAclOutput, error)

GetObjectAcl get object ACL

objectKey: the name of object
Options: WithVersionID the version of the object

Deprecated: use GetObjectACL of ClientV2 instead

func (*Bucket) HeadObject deprecated

func (bkt *Bucket) HeadObject(ctx context.Context, objectKey string, options ...Option) (*HeadObjectOutput, error)

HeadObject get metadata of an object

objectKey: the name of object
options: WithVersionID which version of this object
  WithRange the range of content,
  WithIfModifiedSince return if the object modified after the given date, otherwise return status code 304
  WithIfUnmodifiedSince, WithIfMatch, WithIfNoneMatch set If-Unmodified-Since, If-Match and If-None-Match

Deprecated: use HeadObject of ClientV2 instead

func (*Bucket) ListMultipartUploads deprecated

func (bkt *Bucket) ListMultipartUploads(ctx context.Context, input *ListMultipartUploadsInput, options ...Option) (*ListMultipartUploadsOutput, error)

ListMultipartUploads list multipart uploads

Deprecated: use ListMultipartUploads of ClientV2 instead

func (*Bucket) ListObjectVersions deprecated

func (bkt *Bucket) ListObjectVersions(ctx context.Context, input *ListObjectVersionsInput, options ...Option) (*ListObjectVersionsOutput, error)

ListObjectVersions list multi-version objects of a bucket

Deprecated: use ListObjectV2Versions of ClientV2 instead

func (*Bucket) ListObjects deprecated

func (bkt *Bucket) ListObjects(ctx context.Context, input *ListObjectsInput, options ...Option) (*ListObjectsOutput, error)

ListObjects list objects of a bucket

Deprecated: use ListObjects of ClientV2 instead

func (*Bucket) ListUploadedParts deprecated

func (bkt *Bucket) ListUploadedParts(ctx context.Context, input *ListUploadedPartsInput, options ...Option) (*ListUploadedPartsOutput, error)

ListUploadedParts List Uploaded Parts

objectKey: the object name
input: key, uploadID and other parameters

Deprecated: use ListParts of ClientV2 instead

func (*Bucket) PutFetchTask added in v2.1.8

func (bkt *Bucket) PutFetchTask(ctx context.Context, input *PutFetchTaskInput, options ...Option) (*PutFetchTaskOutput, error)

PutFetchTask put a fetch task to a bucket options:

WithMeta set meta header(s)
WithServerSideEncryptionCustomer set server side encryption options
WithACL WithACLGrantFullControl WithACLGrantRead WithACLGrantReadAcp WithACLGrantWrite WithACLGrantWriteAcp set object acl

Calling PutFetchTask will return immediately after the task created.

func (*Bucket) PutObject deprecated

func (bkt *Bucket) PutObject(ctx context.Context, objectKey string, content io.Reader, options ...Option) (*PutObjectOutput, error)

PutObject put an object

objectKey: the name of object
content: the content of object
options: WithContentType set Content-Type,
  WithContentDisposition set Content-Disposition,
  WithContentLanguage set Content-Language,
  WithContentEncoding set Content-Encoding,
  WithCacheControl set Cache-Control,
  WithExpires set Expires,
  WithMeta set meta header(s),
  WithContentSHA256 set Content-Sha256,
  WithContentMD5 set Content-MD5
  WithExpires set Expires,
  WithServerSideEncryptionCustomer set server side encryption options
  WithACL WithACLGrantFullControl WithACLGrantRead WithACLGrantReadAcp WithACLGrantWrite WithACLGrantWriteAcp set object acl

NOTICE: only content with a known length is supported now,

e.g, bytes.Buffer, bytes.Reader, strings.Reader, os.File, io.LimitedReader, net.Buffers.
if the parameter content(an io.Reader) is not one of these,
please use io.LimitReader(reader, length) to wrap this reader or use the WithContentLength option.

Deprecated: use PutObject of ClientV2 instead

func (*Bucket) PutObjectAcl deprecated

func (bkt *Bucket) PutObjectAcl(ctx context.Context, input *PutObjectAclInput, options ...Option) (*PutObjectAclOutput, error)

PutObjectAcl AclGrant, AclRules can not set both.

Deprecated: ues PutObjectACL of ClientV2 instead

func (*Bucket) SetObjectMeta deprecated

func (bkt *Bucket) SetObjectMeta(ctx context.Context, objectKey string, options ...Option) (*SetObjectMetaOutput, error)

SetObjectMeta overwrites metadata of the object

objectKey: the name of object
options: WithContentType set Content-Type,
  WithContentDisposition set Content-Disposition,
  WithContentLanguage set Content-Language,
  WithContentEncoding set Content-Encoding,
  WithCacheControl set Cache-Control,
  WithExpires set Expires,
  WithMeta set meta header(s),
  WithVersionID which version of this object will be set

NOTICE: SetObjectMeta always overwrites all previous metadata

Deprecated: use SetObjectMeta of ClientV2 instead

func (*Bucket) UploadPart deprecated

func (bkt *Bucket) UploadPart(ctx context.Context, input *UploadPartInput, options ...Option) (*UploadPartOutput, error)

UploadPart upload a part for a multipart upload operation input: the parameters, some fields is required, e.g. Key, UploadID, PartNumber and PartNumber

If uploading 'Content' with known Content-Length, please add option tos.WithContentLength

Deprecated: use UploadPart of ClientV2 instead

func (*Bucket) UploadPartCopy deprecated

func (bkt *Bucket) UploadPartCopy(ctx context.Context, input *UploadPartCopyInput, options ...Option) (*UploadPartCopyOutput, error)

UploadPartCopy copy a part of object as a part of a multipart upload operation

input: uploadID, DestinationKey, SourceBucket, SourceKey and other parameters,
options: WithCopySourceIfMatch WithCopySourceIfNoneMatch WithCopySourceIfModifiedSince WithCopySourceIfUnmodifiedSince set copy conditions

Deprecated: use UploadPartCopy of ClientV2 instead

type BucketPolicy

type BucketPolicy struct {
	Policy string `json:"Policy,omitempty"`
}

type CancelHook

type CancelHook interface {
	// Cancel 取消断点上传\断点下载事, isAbort 为 true 时删除上下文信息和临时文件,为 false 时只是中断当前执行,该接口只能调用一次
	Cancel(isAbort bool)
	// contains filtered or unexported methods
}

func NewCancelHook added in v2.2.0

func NewCancelHook() CancelHook

type ChecksumError

type ChecksumError struct {
	RequestID        string `json:"RequestId,omitempty"`
	ExpectedChecksum string `json:"ExpectedChecksum,omitempty"`
	ActualChecksum   string `json:"ActualChecksum,omitempty"`
}

func (*ChecksumError) Error

func (ce *ChecksumError) Error() string

type Client deprecated

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

Client TOS Client use NewClient to create a new Client

example:

client, err := NewClient(endpoint, WithCredentials(credentials), WithRegion(region))
if err != nil {
   // ...
}
// do something

if you only access the public bucket:

client, err := NewClient(endpoint)
// do something

Deprecated: use ClientV2 instead

func NewClient

func NewClient(endpoint string, options ...ClientOption) (*Client, error)

NewClient create a new Tos Client

endpoint: access endpoint
options: WithCredentials set Credentials
  WithRegion set region, this is required if WithCredentials is used
  WithSocketTimeout set read-write timeout
  WithTransportConfig set TransportConfig
  WithTransport set self-defined Transport

func (*Client) Bucket deprecated

func (cli *Client) Bucket(bucket string) (*Bucket, error)

Bucket create a Bucket handle

Deprecated: request with bucket handle is deprecated, use ClientV2 instead

func (*Client) CreateBucket deprecated

func (cli *Client) CreateBucket(ctx context.Context, input *CreateBucketInput) (*CreateBucketOutput, error)

CreateBucket create a bucket

Deprecated: use CreateBucket of ClientV2 instead

func (*Client) DeleteBucket deprecated

func (cli *Client) DeleteBucket(ctx context.Context, bucket string) (*DeleteBucketOutput, error)

DeleteBucket delete a bucket

Deprecated: use DeleteBucket of ClientV2 instead

func (*Client) DeleteBucketPolicy

func (cli *Client) DeleteBucketPolicy(ctx context.Context, bucket string) (*DeleteBucketPolicyOutput, error)

DeleteBucketPolicy delete bucket access policy

func (*Client) GetBucketPolicy

func (cli *Client) GetBucketPolicy(ctx context.Context, bucket string) (*GetBucketPolicyOutput, error)

GetBucketPolicy get bucket access policy

func (*Client) GetBucketVersioning

func (cli *Client) GetBucketVersioning(ctx context.Context, bucket string) (*GetBucketVersioningOutput, error)

GetBucketVersioning get the multi-version status of a bucket

func (*Client) HeadBucket deprecated

func (cli *Client) HeadBucket(ctx context.Context, bucket string) (*HeadBucketOutput, error)

HeadBucket get some info of a bucket

Deprecated: use HeadBucket of ClientV2 instead

func (*Client) ListBuckets deprecated

func (cli *Client) ListBuckets(ctx context.Context, _ *ListBucketsInput) (*ListBucketsOutput, error)

ListBuckets list the buckets that the AK can access

Deprecated: use ListBuckets of ClientV2 instead

func (*Client) PreSignedURL

func (cli *Client) PreSignedURL(httpMethod string, bucket, objectKey string, ttl time.Duration, options ...Option) (string, error)

PreSignedURL return pre-signed url

 httpMethod: HTTP method, {
   PutObject: http.MethodPut
   GetObject: http.MethodGet
   HeadObject: http.MethodHead
   DeleteObject: http.MethodDelete
 },
 bucket: the bucket name
 objectKey: the object name
 ttl: the time-to-live of signed URL
 options: WithVersionID the version id of the object
Deprecated: use PreSignedURL of ClientV2 instead

func (*Client) PutBucketPolicy

func (cli *Client) PutBucketPolicy(ctx context.Context, bucket string, policy *BucketPolicy) (*PutBucketPolicyOutput, error)

PutBucketPolicy set bucket access policy

type ClientOption

type ClientOption func(*Client)

func WithAutoRecognizeContentType

func WithAutoRecognizeContentType(enable bool) ClientOption

WithAutoRecognizeContentType set to recognize Content-Type or not, the default is enabled.

func WithConnectionTimeout

func WithConnectionTimeout(timeout time.Duration) ClientOption

WithConnectionTimeout set timeout for constructing connection

func WithContentTypeRecognizer

func WithContentTypeRecognizer(recognizer ContentTypeRecognizer) ClientOption

WithContentTypeRecognizer set ContentTypeRecognizer to recognize Content-Type, the default is ExtensionBasedContentTypeRecognizer

func WithCredentials

func WithCredentials(credentials Credentials) ClientOption

WithCredentials set Credentials

see StaticCredentials, WithoutSecretKeyCredentials and FederationCredentials

func WithDNSCacheTime added in v2.3.0

func WithDNSCacheTime(dnsCacheTime int) ClientOption

WithDNSCacheTime set dnsCacheTime in Minute

func WithEnableCRC added in v2.2.0

func WithEnableCRC(enableCRC bool) ClientOption

WithEnableCRC set if check crc after uploading object. Checking crc is enabled by default.

func WithEnableVerifySSL

func WithEnableVerifySSL(enable bool) ClientOption

WithEnableVerifySSL set whether a client verifies the server's certificate chain and host name.

func WithHTTPTransport added in v2.1.1

func WithHTTPTransport(transport http.RoundTripper) ClientOption

WithHTTPTransport set Transport of http.Client

func WithIdleConnTimeout

func WithIdleConnTimeout(timeout time.Duration) ClientOption

WithIdleConnTimeout set max idle time of a http connection

func WithLogger added in v2.2.0

func WithLogger(logger Logger) ClientOption

WithLogger sets the tos sdk logger

func WithMaxConnections

func WithMaxConnections(max int) ClientOption

WithMaxConnections set maximum number of http connections

func WithMaxRetryCount added in v2.2.0

func WithMaxRetryCount(retryCount int) ClientOption

// WithMaxRetryCount set MaxRetryCount

func WithPathAccessMode deprecated

func WithPathAccessMode(pathAccessMode bool) ClientOption

WithPathAccessMode url mode is path model or default mode

Deprecated: This option is deprecated. Setting PathAccessMode will be ignored silently.

func WithProxy added in v2.3.0

func WithProxy(proxy *Proxy) ClientOption

WithProxy set http Proxy for tos client

func WithRegion

func WithRegion(region string) ClientOption

WithRegion set region

func WithRequestTimeout

func WithRequestTimeout(timeout time.Duration) ClientOption

WithRequestTimeout set timeout for single http request

func WithSigner

func WithSigner(signer Signer) ClientOption

WithSigner for self-defined Signer

func WithSocketTimeout

func WithSocketTimeout(readTimeout, writeTimeout time.Duration) ClientOption

WithSocketTimeout set read-write timeout

func WithTransport deprecated

func WithTransport(transport Transport) ClientOption

WithTransport set Transport

Deprecated: this function is Deprecated. If you want to set http.Transport use WithHTTPTransport instead

func WithTransportConfig

func WithTransportConfig(config *TransportConfig) ClientOption

WithTransportConfig set TransportConfig

func WithUserAgentSuffix

func WithUserAgentSuffix(suffix string) ClientOption

WithUserAgentSuffix set suffix of user-agent

type ClientV2

type ClientV2 struct {
	Client
}

ClientV2 TOS ClientV2 use NewClientV2 to create a new ClientV2

example:

client, err := NewClientV2(endpoint, WithCredentials(credentials), WithRegion(region))
if err != nil {
   // ...
}
// do something

if you only access the public bucket:

client, err := NewClientV2(endpoint)
// do something

func NewClientV2

func NewClientV2(endpoint string, options ...ClientOption) (*ClientV2, error)

NewClientV2 create a new Tos ClientV2

endpoint: access endpoint
options: WithCredentials set Credentials
  WithRegion set region, this is required if WithCredentials is used.
  If Region is supported and the Endpoint parameter is not set, the Endpoint will be resolved automatically
  WithSocketTimeout set read-write timeout
  WithTransportConfig set TransportConfig
  WithTransport set self-defined Transport
  WithLogger set self-defined Logger
  WithEnableCRC set CRC switch.
  WithMaxRetryCount  set Max Retry Count

func (*ClientV2) AbortMultipartUpload

func (cli *ClientV2) AbortMultipartUpload(ctx context.Context, input *AbortMultipartUploadInput) (*AbortMultipartUploadOutput, error)

AbortMultipartUpload abort a multipart upload operation

func (*ClientV2) AppendObjectV2

func (cli *ClientV2) AppendObjectV2(ctx context.Context, input *AppendObjectV2Input) (*AppendObjectV2Output, error)

AppendObjectV2 append content at the tail of an appendable object

func (*ClientV2) Close added in v2.1.2

func (cli *ClientV2) Close()

func (*ClientV2) CompleteMultipartUploadV2

func (cli *ClientV2) CompleteMultipartUploadV2(
	ctx context.Context, input *CompleteMultipartUploadV2Input) (*CompleteMultipartUploadV2Output, error)

CompleteMultipartUploadV2 complete a multipart upload operation

func (*ClientV2) CopyObject

func (cli *ClientV2) CopyObject(ctx context.Context, input *CopyObjectInput) (*CopyObjectOutput, error)

CopyObject copy an object

func (*ClientV2) CreateBucketV2

func (cli *ClientV2) CreateBucketV2(ctx context.Context, input *CreateBucketV2Input) (*CreateBucketV2Output, error)

CreateBucketV2 create a bucket

func (*ClientV2) CreateMultipartUploadV2

func (cli *ClientV2) CreateMultipartUploadV2(
	ctx context.Context,
	input *CreateMultipartUploadV2Input) (*CreateMultipartUploadV2Output, error)

CreateMultipartUploadV2 create a multipart upload operation

func (*ClientV2) DeleteBucket

func (cli *ClientV2) DeleteBucket(ctx context.Context, input *DeleteBucketInput) (*DeleteBucketOutput, error)

DeleteBucket delete a bucket.Deleting a non-empty bucket is not allowed. A bucket is empty only if there is no exist object and uncanceled segmented tasks.

func (*ClientV2) DeleteBucketCORS added in v2.1.10

func (cli *ClientV2) DeleteBucketCORS(ctx context.Context, input *DeleteBucketCORSInput) (*DeleteBucketCORSOutput, error)

DeleteBucketCORS delete the bucket's all CORS settings.

func (*ClientV2) DeleteMultiObjects

func (cli *ClientV2) DeleteMultiObjects(ctx context.Context, input *DeleteMultiObjectsInput) (*DeleteMultiObjectsOutput, error)

DeleteMultiObjects delete multi-objects

func (*ClientV2) DeleteObjectV2

func (cli *ClientV2) DeleteObjectV2(ctx context.Context, input *DeleteObjectV2Input) (*DeleteObjectV2Output, error)

DeleteObjectV2 delete an object

func (*ClientV2) DownloadFile added in v2.2.0

func (cli *ClientV2) DownloadFile(ctx context.Context, input *DownloadFileInput) (*DownloadFileOutput, error)

func (*ClientV2) GetBucketCORS added in v2.1.10

func (cli *ClientV2) GetBucketCORS(ctx context.Context, input *GetBucketCORSInput) (*GetBucketCORSOutput, error)

GetBucketCORS get the bucket's CORS settings.

func (*ClientV2) GetObjectACL

func (cli *ClientV2) GetObjectACL(ctx context.Context, input *GetObjectACLInput) (*GetObjectACLOutput, error)

GetObjectACL get object ACL

func (*ClientV2) GetObjectToFile

func (cli *ClientV2) GetObjectToFile(ctx context.Context, input *GetObjectToFileInput) (*GetObjectToFileOutput, error)

GetObjectToFile get object and write it to file

func (*ClientV2) GetObjectV2

func (cli *ClientV2) GetObjectV2(ctx context.Context, input *GetObjectV2Input) (*GetObjectV2Output, error)

GetObjectV2 get data and metadata of an object

func (*ClientV2) HeadBucket

func (cli *ClientV2) HeadBucket(ctx context.Context, input *HeadBucketInput) (*HeadBucketOutput, error)

HeadBucket get some info of a bucket

func (*ClientV2) HeadObjectV2

func (cli *ClientV2) HeadObjectV2(ctx context.Context, input *HeadObjectV2Input) (*HeadObjectV2Output, error)

HeadObjectV2 get metadata of an object

func (*ClientV2) ListBuckets added in v2.1.5

func (cli *ClientV2) ListBuckets(ctx context.Context, _ *ListBucketsInput) (*ListBucketsOutput, error)

ListBuckets list the buckets that the AK can access

func (*ClientV2) ListMultipartUploadsV2

func (cli *ClientV2) ListMultipartUploadsV2(
	ctx context.Context,
	input *ListMultipartUploadsV2Input) (*ListMultipartUploadsV2Output, error)

ListMultipartUploadsV2 list multipart uploads

func (*ClientV2) ListObjectVersionsV2

func (cli *ClientV2) ListObjectVersionsV2(
	ctx context.Context,
	input *ListObjectVersionsV2Input) (*ListObjectVersionsV2Output, error)

ListObjectVersionsV2 list multi-version objects of a bucket

func (*ClientV2) ListObjectsV2

func (cli *ClientV2) ListObjectsV2(ctx context.Context, input *ListObjectsV2Input) (*ListObjectsV2Output, error)

ListObjectsV2 list objects of a bucket

func (*ClientV2) ListParts

func (cli *ClientV2) ListParts(ctx context.Context, input *ListPartsInput) (*ListPartsOutput, error)

ListParts List Uploaded Parts

func (*ClientV2) PreSignedURL

func (cli *ClientV2) PreSignedURL(input *PreSignedURLInput) (*PreSignedURLOutput, error)

PreSignedURL return pre-signed url

func (*ClientV2) PutBucketCORS added in v2.1.10

func (cli *ClientV2) PutBucketCORS(ctx context.Context, input *PutBucketCORSInput) (*PutBucketCORSOutput, error)

PutBucketCORS upsert the bucket's CORS settings.

func (*ClientV2) PutObjectACL

func (cli *ClientV2) PutObjectACL(ctx context.Context, input *PutObjectACLInput) (*PutObjectACLOutput, error)

PutObjectACL put object ACL

func (*ClientV2) PutObjectFromFile

func (cli *ClientV2) PutObjectFromFile(ctx context.Context, input *PutObjectFromFileInput) (*PutObjectFromFileOutput, error)

PutObjectFromFile put an object from file

func (*ClientV2) PutObjectV2

func (cli *ClientV2) PutObjectV2(ctx context.Context, input *PutObjectV2Input) (*PutObjectV2Output, error)

PutObjectV2 put an object

func (*ClientV2) SetHTTPTransport added in v2.1.2

func (cli *ClientV2) SetHTTPTransport(transport http.RoundTripper)

func (*ClientV2) SetObjectMeta

func (cli *ClientV2) SetObjectMeta(ctx context.Context, input *SetObjectMetaInput) (*SetObjectMetaOutput, error)

SetObjectMeta overwrites metadata of the object

func (*ClientV2) UploadFile

func (cli *ClientV2) UploadFile(ctx context.Context, input *UploadFileInput) (output *UploadFileOutput, err error)

func (*ClientV2) UploadPartCopyV2

func (cli *ClientV2) UploadPartCopyV2(
	ctx context.Context,
	input *UploadPartCopyV2Input) (*UploadPartCopyV2Output, error)

UploadPartCopyV2 copy a part of object as a part of a multipart upload operation

func (*ClientV2) UploadPartFromFile

func (cli *ClientV2) UploadPartFromFile(ctx context.Context, input *UploadPartFromFileInput) (*UploadPartFromFileOutput, error)

UploadPartFromFile upload a part for a multipart upload operation from file

func (*ClientV2) UploadPartV2

func (cli *ClientV2) UploadPartV2(ctx context.Context, input *UploadPartV2Input) (*UploadPartV2Output, error)

UploadPartV2 upload a part for a multipart upload operation

type CommonHeaders

type CommonHeaders struct {
	ContentLength      int64        `location:"header" locationName:"Content-Length"`
	ContentMD5         string       `location:"header" locationName:"Content-MD5"`
	ContentSHA256      string       `location:"header" locationName:"X-Tos-Content-Sha256"`
	CacheControl       string       `location:"header" locationName:"Cache-Control"`
	ContentDisposition string       `location:"header" locationName:"Content-Disposition" encodeChinese:"true"`
	ContentEncoding    string       `location:"header" locationName:"Content-Encoding"`
	ContentLanguage    string       `location:"header" locationName:"Content-Language"`
	ContentType        string       `location:"header" locationName:"Content-Type"`
	Expires            time.Time    `location:"header" locationName:"Expires"`
	ACL                enum.ACLType `location:"header" locationName:"X-Tos-Acl"`

	GrantFullControl string `location:"header" locationName:"X-Tos-Grant-Full-Control"` // optional
	GrantRead        string `location:"header" locationName:"X-Tos-Grant-Read"`         // optional
	GrantReadAcp     string `location:"header" locationName:"X-Tos-Grant-Read-Acp"`     // optional
	GrantWriteAcp    string `location:"header" locationName:"X-Tos-Grant-Write-Acp"`    // optional

	WebsiteRedirectLocation string                `location:"header" locationName:"X-Tos-Website-Redirect-Location"`
	StorageClass            enum.StorageClassType `location:"header" locationName:"X-Tos-Storage-Class"`
}

type CompleteMultipartUploadInput

type CompleteMultipartUploadInput struct {
	Key           string                  `json:"Key,omitempty"`
	UploadID      string                  `json:"UploadId,omitempty"`
	UploadedParts []MultipartUploadedPart `json:"UploadedParts,omitempty"`
}

type CompleteMultipartUploadOutput

type CompleteMultipartUploadOutput struct {
	RequestInfo `json:"-"`
	VersionID   string `json:"VersionId,omitempty"`
}

type CompleteMultipartUploadV2Input

type CompleteMultipartUploadV2Input struct {
	Bucket   string
	Key      string
	UploadID string `location:"query" locationName:"uploadId"`
	Parts    []UploadedPartV2
}

type CompleteMultipartUploadV2Output

type CompleteMultipartUploadV2Output struct {
	RequestInfo
	Bucket        string
	Key           string
	ETag          string
	Location      string
	VersionID     string
	HashCrc64ecma uint64
}

type Config

type Config struct {
	Endpoint        string
	Region          string
	TransportConfig TransportConfig
}

type ContentTypeRecognizer

type ContentTypeRecognizer interface {
	ContentType(objectKey string) string
}

type CopyObjectInput

type CopyObjectInput struct {
	Bucket             string
	Key                string
	SrcBucket          string
	SrcKey             string
	SrcVersionID       string
	CacheControl       string       `location:"header" locationName:"Cache-Control"`
	ContentDisposition string       `location:"header" locationName:"Content-Disposition" encodeChinese:"true"`
	ContentEncoding    string       `location:"header" locationName:"Content-Encoding"`
	ContentLanguage    string       `location:"header" locationName:"Content-Language"`
	ContentType        string       `location:"header" locationName:"Content-Type"`
	Expires            time.Time    `location:"header" locationName:"Expires"`
	ACL                enum.ACLType `location:"header" locationName:"X-Tos-Acl"`

	GrantFullControl string `location:"header" locationName:"X-Tos-Grant-Full-Control"` // optional
	GrantRead        string `location:"header" locationName:"X-Tos-Grant-Read"`         // optional
	GrantReadAcp     string `location:"header" locationName:"X-Tos-Grant-Read-Acp"`     // optional
	GrantWriteAcp    string `location:"header" locationName:"X-Tos-Grant-Write-Acp"`    // optional

	WebsiteRedirectLocation string                `location:"header" locationName:"X-Tos-Website-Redirect-Location"`
	StorageClass            enum.StorageClassType `location:"header" locationName:"X-Tos-Storage-Class"`

	CopySourceIfMatch           string    `location:"header" locationName:"X-Tos-Copy-Source-If-Match"`
	CopySourceIfModifiedSince   time.Time `location:"header" locationName:"X-Tos-Copy-Source-If-Modified-Since"`
	CopySourceIfNoneMatch       string    `location:"header" locationName:"X-Tos-Copy-Source-If-None-Match"`
	CopySourceIfUnmodifiedSince time.Time `location:"header" locationName:"X-Tos-Copy-Source-If-Unmodified-Since"`

	CopySourceSSECAlgorithm string `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Algorithm"`
	CopySourceSSECKey       string `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Key"`
	CopySourceSSECKeyMD5    string `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Key-MD5"`
	ServerSideEncryption    string `location:"header" locationName:"X-Tos-Server-Side-Encryption"`

	MetadataDirective enum.MetadataDirectiveType `location:"header" locationName:"X-Tos-Metadata-Directive"`
	Meta              map[string]string          `location:"headers"`
}

type CopyObjectOutput

type CopyObjectOutput struct {
	RequestInfo     `json:"-"`
	VersionID       string `json:"VersionId,omitempty"`
	SourceVersionID string `json:"SourceVersionId,omitempty"`
	ETag            string `json:"ETag,omitempty"`         // at body
	LastModified    string `json:"LastModified,omitempty"` // at body
}

type CopySource

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

type CorsRule added in v2.1.10

type CorsRule struct {
	AllowedOrigin []string `json:"AllowedOrigins,omitempty"`
	AllowedMethod []string `json:"AllowedMethods,omitempty"`
	AllowedHeader []string `json:"AllowedHeaders,omitempty"`
	ExposeHeader  []string `json:"ExposeHeaders,omitempty"`
	MaxAgeSeconds int      `json:"MaxAgeSeconds,omitempty"`
}

type CreateBucketInput

type CreateBucketInput struct {
	Bucket           string `json:"Bucket,omitempty"`           // required
	ACL              string `json:"ACL,omitempty"`              // optional
	GrantFullControl string `json:"GrantFullControl,omitempty"` // optional
	GrantRead        string `json:"GrantRead,omitempty"`        // optional
	GrantReadAcp     string `json:"GrantReadAcp,omitempty"`     // optional
	GrantWrite       string `json:"GrantWrite,omitempty"`       // optional
	GrantWriteAcp    string `json:"GrantWriteAcp,omitempty"`    // optional
}

type CreateBucketOutput

type CreateBucketOutput struct {
	RequestInfo `json:"-"`
	Location    string `json:"Location,omitempty"`
}

type CreateBucketV2Input

type CreateBucketV2Input struct {
	Bucket           string                // required
	ACL              enum.ACLType          `location:"header" locationName:"X-Tos-Acl"`                // optional
	GrantFullControl string                `location:"header" locationName:"X-Tos-Grant-Full-Control"` // optional
	GrantRead        string                `location:"header" locationName:"X-Tos-Grant-Read"`         // optional
	GrantReadAcp     string                `location:"header" locationName:"X-Tos-Grant-Read-Acp"`     // optional
	GrantWrite       string                `location:"header" locationName:"X-Tos-Grant-Write"`        // optional
	GrantWriteAcp    string                `location:"header" locationName:"X-Tos-Grant-Write-Acp"`    // optional
	StorageClass     enum.StorageClassType `location:"header" locationName:"X-Tos-Storage-Class"`      // setting the default storage type for buckets
	AzRedundancy     enum.AzRedundancyType `location:"header" locationName:"X-Tos-Az-Redundancy"`      // setting the AZ type for buckets
}

type CreateBucketV2Output

type CreateBucketV2Output struct {
	CreateBucketOutput
}

type CreateMultipartUploadOutput

type CreateMultipartUploadOutput struct {
	RequestInfo          `json:"-"`
	Bucket               string `json:"Bucket,omitempty"`
	Key                  string `json:"Key,omitempty"`
	UploadID             string `json:"UploadId,omitempty"`
	SSECustomerAlgorithm string `json:"SSECustomerAlgorithm,omitempty"`
	SSECustomerKeyMD5    string `json:"SSECustomerKeyMD5,omitempty"`
}

type CreateMultipartUploadV2Input

type CreateMultipartUploadV2Input struct {
	Bucket             string
	Key                string
	EncodingType       string       `location:"query" locationName:"encoding-type"` // "" or "url"
	CacheControl       string       `location:"header" locationName:"Cache-Control"`
	ContentDisposition string       `location:"header" locationName:"Content-Disposition" encodeChinese:"true"`
	ContentEncoding    string       `location:"header" locationName:"Content-Encoding"`
	ContentLanguage    string       `location:"header" locationName:"Content-Language"`
	ContentType        string       `location:"header" locationName:"Content-Type"`
	Expires            time.Time    `location:"header" locationName:"Expires"`
	ACL                enum.ACLType `location:"header" locationName:"X-Tos-Acl"`

	GrantFullControl string `location:"header" locationName:"X-Tos-Grant-Full-Control"` // optional
	GrantRead        string `location:"header" locationName:"X-Tos-Grant-Read"`         // optional
	GrantReadAcp     string `location:"header" locationName:"X-Tos-Grant-Read-Acp"`     // optional
	GrantWriteAcp    string `location:"header" locationName:"X-Tos-Grant-Write-Acp"`    // optional

	WebsiteRedirectLocation string                `location:"header" locationName:"X-Tos-Website-Redirect-Location"`
	StorageClass            enum.StorageClassType `location:"header" locationName:"X-Tos-Storage-Class"`
	SSECAlgorithm           string                `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Algorithm"`
	SSECKey                 string                `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Key"`
	SSECKeyMD5              string                `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Key-MD5"`
	ServerSideEncryption    string                `location:"header" locationName:"X-Tos-Server-Side-Encryption"`
	Meta                    map[string]string     `location:"headers"`
}

type CreateMultipartUploadV2Output

type CreateMultipartUploadV2Output struct {
	RequestInfo   `json:"-"`
	Bucket        string `json:"Bucket,omitempty"`
	Key           string `json:"Key,omitempty"`
	UploadID      string `json:"UploadID,omitempty"`
	SSECAlgorithm string `json:"SSECAlgorithm,omitempty"`
	SSECKeyMD5    string `json:"SSECKeyMD5,omitempty"`
	EncodingType  string `json:"EncodingType,omitempty"`
}

type Credential

type Credential struct {
	AccessKeyID     string
	AccessKeySecret string
	SecurityToken   string
}

type Credentials

type Credentials interface {
	Credential() Credential
}

Credentials provides Credential

type CustomMeta added in v2.1.3

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

func (*CustomMeta) AllKeys added in v2.1.3

func (c *CustomMeta) AllKeys() []string

func (*CustomMeta) Get added in v2.1.3

func (c *CustomMeta) Get(key string) (val string, ok bool)

func (*CustomMeta) Range added in v2.1.3

func (c *CustomMeta) Range(f func(key, val string) bool)

type DataTransferListener

type DataTransferListener interface {
	DataTransferStatusChange(status *DataTransferStatus)
}

type DataTransferStatus

type DataTransferStatus struct {
	TotalBytes    int64
	ConsumedBytes int64 // bytes read/written
	RWOnceBytes   int64 // bytes read/written this time
	Type          enum.DataTransferType
}

type DefaultTransport

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

func NewDefaultTransport

func NewDefaultTransport(config *TransportConfig) *DefaultTransport

NewDefaultTransport create a DefaultTransport with config

func NewDefaultTransportWithClient

func NewDefaultTransportWithClient(client http.Client) *DefaultTransport

NewDefaultTransportWithClient crate a DefaultTransport with a http.Client

func (*DefaultTransport) RoundTrip

func (dt *DefaultTransport) RoundTrip(ctx context.Context, req *Request) (*Response, error)

func (*DefaultTransport) WithDefaultTransportLogger added in v2.2.0

func (d *DefaultTransport) WithDefaultTransportLogger(logger Logger)

type DeleteBucketCORSInput added in v2.1.10

type DeleteBucketCORSInput struct {
	Bucket string
}

type DeleteBucketCORSOutput added in v2.1.10

type DeleteBucketCORSOutput struct {
	RequestInfo `json:"-"`
}

type DeleteBucketInput

type DeleteBucketInput struct {
	Bucket string
}

type DeleteBucketOutput

type DeleteBucketOutput struct {
	RequestInfo `json:"-"`
}

type DeleteBucketPolicyOutput

type DeleteBucketPolicyOutput struct {
	RequestInfo `json:"-"`
}

type DeleteError

type DeleteError struct {
	Code      string `json:"Code,omitempty"`
	Message   string `json:"Message,omitempty"`
	Key       string `json:"Key,omitempty"`
	VersionID string `json:"VersionId,omitempty"`
}

type DeleteMultiObjectsInput

type DeleteMultiObjectsInput struct {
	Bucket  string
	Objects []ObjectTobeDeleted `json:"Objects,omitempty"`
	Quiet   bool                `json:"Quiet,omitempty"`
}

type DeleteMultiObjectsOutput

type DeleteMultiObjectsOutput struct {
	RequestInfo `json:"-"`
	Deleted     []DeletedV2   `json:"Deleted,omitempty"` // 删除成功的Object列表
	Error       []DeleteError `json:"Error,omitempty"`   // 删除失败的Object列表
}

type DeleteObjectOutput

type DeleteObjectOutput struct {
	RequestInfo  `json:"-"`
	DeleteMarker bool   `json:"DeleteMarker,omitempty"`
	VersionID    string `json:"VersionId,omitempty"`
}

type DeleteObjectV2Input

type DeleteObjectV2Input struct {
	Bucket    string
	Key       string
	VersionID string `location:"query" locationName:"versionId"`
}

type DeleteObjectV2Output

type DeleteObjectV2Output struct {
	DeleteObjectOutput
}

type Deleted

type Deleted struct {
	Key                   string `json:"Key,omitempty"`
	VersionID             string `json:"VersionId,omitempty"`
	DeleteMarker          *bool  `json:"DeleteMarker,omitempty"`
	DeleteMarkerVersionID string `json:"DeleteMarkerVersionId,omitempty"`
}

type DeletedV2 added in v2.1.3

type DeletedV2 struct {
	Key                   string `json:"Key,omitempty"`
	VersionID             string `json:"VersionId,omitempty"`
	DeleteMarker          bool   `json:"DeleteMarker,omitempty"`
	DeleteMarkerVersionID string `json:"DeleteMarkerVersionId,omitempty"`
}

type DownloadEvent

type DownloadEvent struct {
	Type           enum.DownloadEventType
	Err            error // not empty when it occurs when failed, aborted event occurs
	Bucket         string
	Key            string
	VersionID      string
	FilePath       string  // path of the file to download to
	CheckpointFile *string // path to checkpoint file
	TempFilePath   *string // path fo the temp file
	// not empty when download part event occurs
	DowloadPartInfo *DownloadPartInfo
}

type DownloadEventListener

type DownloadEventListener interface {
	EventChange(event *DownloadEvent)
}

type DownloadFileInput

type DownloadFileInput struct {
	HeadObjectV2Input
	FilePath         string
	PartSize         int64
	TaskNum          int
	EnableCheckpoint bool
	CheckpointFile   string

	DownloadEventListener DownloadEventListener
	DataTransferListener  DataTransferListener
	RateLimiter           RateLimiter
	CancelHook            CancelHook // user can not set this filed
	// contains filtered or unexported fields
}

type DownloadFileOutput

type DownloadFileOutput struct {
	HeadObjectV2Output
}

type DownloadPartInfo

type DownloadPartInfo struct {
	PartNumber int
	RangeStart int64
	RangeEnd   int64
}

DownloadPartInfo is returned when DownloadEvent occur

type ETagCheckReadCloser

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

ETagCheckReadCloser checks ETag on read EOF

func NewETagCheckReadCloser

func NewETagCheckReadCloser(reader io.ReadCloser, eTag, requestID string) *ETagCheckReadCloser

func (*ETagCheckReadCloser) Close

func (ec *ETagCheckReadCloser) Close() error

func (*ETagCheckReadCloser) Read

func (ec *ETagCheckReadCloser) Read(p []byte) (n int, err error)

type EmptyContentTypeRecognizer

type EmptyContentTypeRecognizer struct{}

func (EmptyContentTypeRecognizer) ContentType

func (er EmptyContentTypeRecognizer) ContentType(objectKey string) string

type Error

type Error struct {
	StatusCode int    `json:"-"`
	Code       string `json:"Code,omitempty"`
	Message    string `json:"Message,omitempty"`
	RequestID  string `json:"RequestId,omitempty"`
	HostID     string `json:"HostId,omitempty"`
	Resource   string `json:"Resource,omitempty"`
}

func (*Error) Error

func (e *Error) Error() string

type ExtensionBasedContentTypeRecognizer

type ExtensionBasedContentTypeRecognizer struct{}

func (ExtensionBasedContentTypeRecognizer) ContentType

func (er ExtensionBasedContentTypeRecognizer) ContentType(objectKey string) string

type FederationCredentials

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

FederationCredentials implements Credentials interfaces with flushing Credential periodically

func NewFederationCredentials

func NewFederationCredentials(tokenProvider FederationTokenProvider) (*FederationCredentials, error)

NewFederationCredentials FederationCredentials implements Credentials interfaces with flushing Credential periodically

use WithPreFetch set prefetch time

func (*FederationCredentials) Credential

func (fc *FederationCredentials) Credential() Credential

Credential for Credentials interface

func (*FederationCredentials) WithPreFetch

func (fc *FederationCredentials) WithPreFetch(preFetch time.Duration)

WithPreFetch set prefetch time

type FederationToken

type FederationToken struct {
	Credential Credential
	Expiration time.Time
}

FederationToken contains Credential and Credential's expiration time

type FederationTokenProvider

type FederationTokenProvider interface {
	FederationToken() (*FederationToken, error)
}

FederationTokenProvider provides FederationToken

type FetchObjectInput

type FetchObjectInput struct {
	URL           string `json:"URL,omitempty"`           // required
	Key           string `json:"Key,omitempty"`           // required
	IgnoreSameKey bool   `json:"IgnoreSameKey,omitempty"` // optional, default value is false
	ContentMD5    string `json:"ContentMD5,omitempty"`    // hex-encoded md5, optional
}

type FetchObjectOutput

type FetchObjectOutput struct {
	RequestInfo `json:"-"`
	VersionID   string `json:"VersionId,omitempty"` // may be empty
	ETag        string `json:"ETag,omitempty"`
}

type GetBucketCORSInput added in v2.1.10

type GetBucketCORSInput struct {
	Bucket string
}

type GetBucketCORSOutput added in v2.1.10

type GetBucketCORSOutput struct {
	RequestInfo `json:"-"`
	CORSRules   []CorsRule `json:"CORSRules,omitempty"`
}

type GetBucketPolicyOutput

type GetBucketPolicyOutput struct {
	RequestInfo `json:"-"`
	Policy      string `json:"Policy,omitempty"`
}

type GetBucketVersioningOutput

type GetBucketVersioningOutput struct {
	RequestInfo `json:"-"`
	Status      string `json:"Status"`
}

type GetFetchTaskInput added in v2.1.8

type GetFetchTaskInput struct {
	TaskID string `json:"taskID,omitempty"`
}

type GetFetchTaskOutput added in v2.1.8

type GetFetchTaskOutput struct {
	RequestInfo `json:"-"`
	State       string `json:"State,omitempty"`
}

type GetObjectACLInput

type GetObjectACLInput struct {
	Bucket    string
	Key       string
	VersionID string `location:"query" locationName:"versionId"`
}

type GetObjectACLOutput

type GetObjectACLOutput struct {
	RequestInfo `json:"-"`
	VersionID   string    `json:"VersionID,omitempty"`
	Owner       Owner     `json:"Owner,omitempty"`
	Grants      []GrantV2 `json:"Grants,omitempty"`
}

type GetObjectAclOutput

type GetObjectAclOutput struct {
	RequestInfo `json:"-"`
	VersionID   string  `json:"VersionId,omitempty"`
	Owner       Owner   `json:"Owner,omitempty"`
	Grants      []Grant `json:"Grants,omitempty"`
}

type GetObjectBasicOutput

type GetObjectBasicOutput struct {
	RequestInfo
	ContentRange string // don't move into ObjectMetaV2
	ObjectMetaV2
}

type GetObjectOutput

type GetObjectOutput struct {
	RequestInfo  `json:"-"`
	ContentRange string        `json:"ContentRange,omitempty"`
	Content      io.ReadCloser `json:"-"`
	ObjectMeta
}

type GetObjectToFileInput

type GetObjectToFileInput struct {
	GetObjectV2Input
	FilePath string
}

type GetObjectToFileOutput

type GetObjectToFileOutput struct {
	GetObjectBasicOutput
}

type GetObjectV2Input

type GetObjectV2Input struct {
	Bucket     string
	Key        string
	VersionID  string `location:"query" locationName:"versionId"`
	PartNumber int    `location:"query" locationName:"partNumber"`

	IfMatch           string    `location:"header" locationName:"If-Match"`
	IfModifiedSince   time.Time `location:"header" locationName:"If-Modified-Since"`
	IfNoneMatch       string    `location:"header" locationName:"If-None-Match"`
	IfUnmodifiedSince time.Time `location:"header" locationName:"If-Unmodified-Since"`

	SSECAlgorithm string `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Algorithm"`
	SSECKey       string `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Key"`
	SSECKeyMD5    string `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Key-MD5"`

	ResponseCacheControl       string    `location:"query" locationName:"Cache-Control"`
	ResponseContentDisposition string    `location:"query" locationName:"Content-Disposition"`
	ResponseContentEncoding    string    `location:"query" locationName:"Content-Encoding"`
	ResponseContentLanguage    string    `location:"query" locationName:"Content-Language"`
	ResponseContentType        string    `location:"query" locationName:"Content-Type"`
	ResponseExpires            time.Time `location:"query" locationName:"Expires"`

	RangeStart int64
	RangeEnd   int64

	DataTransferListener DataTransferListener
	RateLimiter          RateLimiter
}

type GetObjectV2Output

type GetObjectV2Output struct {
	GetObjectBasicOutput
	Content io.ReadCloser
}

type Grant

type Grant struct {
	Grantee    Grantee             `json:"Grantee,omitempty"`
	Permission enum.PermissionType `json:"Permission,omitempty"`
}

type GrantV2 added in v2.1.3

type GrantV2 struct {
	GranteeV2  GranteeV2           `json:"Grantee,omitempty"`
	Permission enum.PermissionType `json:"Permission,omitempty"`
}

type Grantee

type Grantee struct {
	ID          string `json:"ID,omitempty"`
	DisplayName string `json:"DisplayName,omitempty"`
	Type        string `json:"Type,omitempty"`
	URI         string `json:"Canned,omitempty"`
}

type GranteeV2 added in v2.1.3

type GranteeV2 struct {
	ID          string
	DisplayName string
	Type        enum.GranteeType
	Canned      enum.CannedType
}

type HeadBucketInput

type HeadBucketInput struct {
	Bucket string
}

type HeadBucketOutput

type HeadBucketOutput struct {
	RequestInfo  `json:"-"`
	Region       string                `json:"Region,omitempty"`
	StorageClass enum.StorageClassType `json:"StorageClass,omitempty"`
	AzRedundancy enum.AzRedundancyType `json:"AzRedundancy"`
}

type HeadObjectOutput

type HeadObjectOutput struct {
	RequestInfo  `json:"-"`
	ContentRange string `json:"ContentRange,omitempty"`
	ObjectMeta
}

type HeadObjectV2Input

type HeadObjectV2Input struct {
	Bucket    string
	Key       string
	VersionID string `location:"query" locationName:"versionId"`

	IfMatch           string    `location:"header" locationName:"If-Match"`
	IfModifiedSince   time.Time `location:"header" locationName:"If-Modified-Since"`
	IfNoneMatch       string    `location:"header" locationName:"If-None-Match"`
	IfUnmodifiedSince time.Time `location:"header" locationName:"If-Unmodified-Since"`

	SSECAlgorithm string `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Algorithm"`
	SSECKey       string `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Key"`
	SSECKeyMD5    string `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Key-MD5"`
}

type HeadObjectV2Output

type HeadObjectV2Output struct {
	RequestInfo `json:"-"`
	ObjectMetaV2
}

type KV

type KV struct {
	Key    string
	Values []string
}

type KVs

type KVs []KV

func (KVs) Len

func (kvs KVs) Len() int

func (KVs) Less

func (kvs KVs) Less(i, j int) bool

func (KVs) Swap

func (kvs KVs) Swap(i, j int)

type ListBucketsInput

type ListBucketsInput struct{}

type ListBucketsOutput

type ListBucketsOutput struct {
	RequestInfo `json:"-"`
	Buckets     []ListedBucket `json:"Buckets,omitempty"`
	Owner       ListedOwner    `json:"Owner,omitempty"`
}

type ListMultipartUploadsInput

type ListMultipartUploadsInput struct {
	Prefix         string `json:"Prefix,omitempty"`
	Delimiter      string `json:"Delimiter,omitempty"`
	KeyMarker      string `json:"KeyMarker,omitempty"`
	UploadIDMarker string `json:"UploadIdMarker,omitempty"`
	MaxUploads     int    `json:"MaxUploads,omitempty"`
}

type ListMultipartUploadsOutput

type ListMultipartUploadsOutput struct {
	RequestInfo        `json:"-"`
	Bucket             string               `json:"Bucket,omitempty"`
	KeyMarker          string               `json:"KeyMarker,omitempty"`
	UploadIdMarker     string               `json:"UploadIdMarker,omitempty"`
	NextKeyMarker      string               `json:"NextKeyMarker,omitempty"`
	NextUploadIdMarker string               `json:"NextUploadIdMarker,omitempty"`
	Delimiter          string               `json:"Delimiter,omitempty"`
	Prefix             string               `json:"Prefix,omitempty"`
	MaxUploads         int32                `json:"MaxUploads,omitempty"`
	IsTruncated        bool                 `json:"IsTruncated,omitempty"`
	Upload             []UploadInfo         `json:"Uploads,omitempty"`
	CommonPrefixes     []UploadCommonPrefix `json:"CommonPrefixes,omitempty"`
}

type ListMultipartUploadsV2Input

type ListMultipartUploadsV2Input struct {
	Bucket         string
	Prefix         string `location:"query" locationName:"uploads"`
	Delimiter      string `location:"query" locationName:"delimiter"`
	KeyMarker      string `location:"query" locationName:"key-marker"`
	UploadIDMarker string `location:"query" locationName:"upload-id-marker"`
	MaxUploads     int    `location:"query" locationName:"max-uploads"`
	EncodingType   string `location:"query" locationName:"encoding-type"` // "" or "url"
}

type ListMultipartUploadsV2Output

type ListMultipartUploadsV2Output struct {
	RequestInfo
	Bucket             string
	Prefix             string
	KeyMarker          string
	UploadIDMarker     string
	MaxUploads         int
	Delimiter          string
	IsTruncated        bool
	EncodingType       string
	NextKeyMarker      string
	NextUploadIDMarker string
	CommonPrefixes     []ListedCommonPrefix
	Uploads            []ListedUpload
}

type ListObjectVersionsInput

type ListObjectVersionsInput struct {
	Prefix          string `location:"query" locationName:"prefix"`
	Delimiter       string `location:"query" locationName:"delimiter"`
	KeyMarker       string `location:"query" locationName:"key-marker"`
	VersionIDMarker string `location:"query" locationName:"version-id-marker"`
	MaxKeys         int    `location:"query" locationName:"max-keys"`
	EncodingType    string `location:"query" locationName:"encoding-type"` // "" or "url"
}

type ListObjectVersionsOutput

type ListObjectVersionsOutput struct {
	RequestInfo         `json:"-"`
	Name                string                    `json:"Name,omitempty"` // bucket name
	Prefix              string                    `json:"Prefix,omitempty"`
	KeyMarker           string                    `json:"KeyMarker,omitempty"`
	VersionIDMarker     string                    `json:"VersionIdMarker,omitempty"`
	Delimiter           string                    `json:"Delimiter,omitempty"`
	EncodingType        string                    `json:"EncodingType,omitempty"`
	MaxKeys             int64                     `json:"MaxKeys,omitempty"`
	NextKeyMarker       string                    `json:"NextKeyMarker,omitempty"`
	NextVersionIDMarker string                    `json:"NextVersionIdMarker,omitempty"`
	IsTruncated         bool                      `json:"IsTruncated,omitempty"`
	CommonPrefixes      []ListedCommonPrefix      `json:"CommonPrefixes,omitempty"`
	Versions            []ListedObjectVersion     `json:"Versions,omitempty"`
	DeleteMarkers       []ListedDeleteMarkerEntry `json:"DeleteMarkers,omitempty"`
}

type ListObjectVersionsV2Input

type ListObjectVersionsV2Input struct {
	Bucket string `json:"Prefix,omitempty"`
	ListObjectVersionsInput
}

type ListObjectVersionsV2Output

type ListObjectVersionsV2Output struct {
	RequestInfo         `json:"-"`
	Name                string                  `json:"Name,omitempty"` // bucket name
	Prefix              string                  `json:"Prefix,omitempty"`
	KeyMarker           string                  `json:"KeyMarker,omitempty"`
	VersionIDMarker     string                  `json:"VersionIdMarker,omitempty"`
	Delimiter           string                  `json:"Delimiter,omitempty"`
	EncodingType        string                  `json:"EncodingType,omitempty"`
	MaxKeys             int                     `json:"MaxKeys,omitempty"`
	NextKeyMarker       string                  `json:"NextKeyMarker,omitempty"`
	NextVersionIDMarker string                  `json:"NextVersionIdMarker,omitempty"`
	IsTruncated         bool                    `json:"IsTruncated,omitempty"`
	CommonPrefixes      []ListedCommonPrefix    `json:"CommonPrefixes,omitempty"`
	Versions            []ListedObjectVersionV2 `json:"Versions,omitempty"`
	DeleteMarkers       []ListedDeleteMarker    `json:"DeleteMarkers,omitempty"`
}

type ListObjectsInput

type ListObjectsInput struct {
	Prefix       string `location:"query" locationName:"prefix"`
	Delimiter    string `location:"query" locationName:"delimiter"`
	Marker       string `location:"query" locationName:"marker"`
	MaxKeys      int    `location:"query" locationName:"max-keys"`
	Reverse      bool   `location:"query" locationName:"reverse"`
	EncodingType string `location:"query" locationName:"encoding-type"` // "" or "url"
}

type ListObjectsOutput

type ListObjectsOutput struct {
	RequestInfo    `json:"-"`
	Name           string               `json:"Name,omitempty"` // bucket name
	Prefix         string               `json:"Prefix,omitempty"`
	Marker         string               `json:"Marker,omitempty"`
	MaxKeys        int64                `json:"MaxKeys,omitempty"`
	NextMarker     string               `json:"NextMarker,omitempty"`
	Delimiter      string               `json:"Delimiter,omitempty"`
	IsTruncated    bool                 `json:"IsTruncated,omitempty"`
	EncodingType   string               `json:"EncodingType,omitempty"`
	CommonPrefixes []ListedCommonPrefix `json:"CommonPrefixes,omitempty"`
	Contents       []ListedObject       `json:"Contents,omitempty"`
}

type ListObjectsV2Input

type ListObjectsV2Input struct {
	Bucket string
	ListObjectsInput
}

type ListObjectsV2Output

type ListObjectsV2Output struct {
	RequestInfo    `json:"-"`
	Name           string               `json:"Name,omitempty"`
	Prefix         string               `json:"Prefix,omitempty"`
	Marker         string               `json:"Marker,omitempty"`
	MaxKeys        int64                `json:"MaxKeys,omitempty"`
	NextMarker     string               `json:"NextMarker,omitempty"`
	Delimiter      string               `json:"Delimiter,omitempty"`
	IsTruncated    bool                 `json:"IsTruncated,omitempty"`
	EncodingType   string               `json:"EncodingType,omitempty"`
	CommonPrefixes []ListedCommonPrefix `json:"CommonPrefixes,omitempty"`
	Contents       []ListedObjectV2     `json:"Contents,omitempty"`
}

type ListPartsInput

type ListPartsInput struct {
	Bucket           string
	Key              string
	UploadID         string `location:"query" locationName:"uploadId"`
	PartNumberMarker int    `location:"query" locationName:"part-number-marker"`
	MaxParts         int    `location:"query" locationName:"max-parts"`
	EncodingType     string `location:"query" locationName:"encoding-type"` // "" or "url"
}

type ListPartsOutput

type ListPartsOutput struct {
	RequestInfo
	Bucket           string
	Key              string
	UploadID         string
	PartNumberMarker int
	MaxParts         int
	IsTruncated      bool
	EncodingType     string

	NextPartNumberMarker int
	StorageClass         enum.StorageClassType
	Owner                Owner
	Parts                []UploadedPartV2
}

type ListUploadedPartsInput

type ListUploadedPartsInput struct {
	Key              string `json:"Key,omitempty"`
	UploadID         string `json:"UploadId,omitempty"`
	MaxParts         int    `json:"MaxParts,omitempty"`             // 最大Part个数
	PartNumberMarker int    `json:"NextPartNumberMarker,omitempty"` // 起始Part的位置
}

type ListUploadedPartsOutput

type ListUploadedPartsOutput struct {
	RequestInfo          `json:"-"`
	Bucket               string         `json:"Bucket,omitempty"`               // Bucket名称
	Key                  string         `json:"Key,omitempty"`                  // Object名称
	UploadID             string         `json:"UploadId,omitempty"`             // 上传ID
	PartNumberMarker     int            `json:"PartNumberMarker,omitempty"`     // 当前页起始位置
	NextPartNumberMarker int            `json:"NextPartNumberMarker,omitempty"` // 下一个Part的位置
	MaxParts             int            `json:"MaxParts,omitempty"`             // 最大Part个数
	IsTruncated          bool           `json:"IsTruncated,omitempty"`          // 是否完全上传完成
	StorageClass         string         `json:"StorageClass,omitempty"`         // 存储类型
	Owner                Owner          `json:"Owner,omitempty"`                // 属主
	UploadedParts        []UploadedPart `json:"Parts,omitempty"`                // 已完成的Part
}

type ListedBucket

type ListedBucket struct {
	CreationDate     string `json:"CreationDate,omitempty"`
	Name             string `json:"Name,omitempty"`
	Location         string `json:"Location,omitempty"`
	ExtranetEndpoint string `json:"ExtranetEndpoint,omitempty"`
	IntranetEndpoint string `json:"IntranetEndpoint,omitempty"`
}

type ListedCommonPrefix

type ListedCommonPrefix struct {
	Prefix string `json:"Prefix,omitempty"`
}

type ListedDeleteMarker

type ListedDeleteMarker struct {
	Key          string
	LastModified time.Time
	IsLatest     bool
	Owner        Owner
	VersionID    string
}

type ListedDeleteMarkerEntry

type ListedDeleteMarkerEntry struct {
	IsLatest     bool   `json:"IsLatest,omitempty"`
	Key          string `json:"Key,omitempty"`
	LastModified string `json:"LastModified,omitempty"`
	Owner        Owner  `json:"Owner,omitempty"`
	VersionID    string `json:"VersionId,omitempty"`
}

type ListedObject

type ListedObject struct {
	Key          string `json:"Key,omitempty"`
	LastModified string `json:"LastModified,omitempty"`
	ETag         string `json:"ETag,omitempty"`
	Size         int64  `json:"Size,omitempty"`
	Owner        Owner  `json:"Owner,omitempty"`
	StorageClass string `json:"StorageClass,omitempty"`
	Type         string `json:"Type,omitempty"`
}

type ListedObjectV2 added in v2.1.3

type ListedObjectV2 struct {
	Key           string
	LastModified  time.Time
	ETag          string
	Size          int64
	Owner         Owner
	StorageClass  enum.StorageClassType
	HashCrc64ecma uint64
}

type ListedObjectVersion

type ListedObjectVersion struct {
	ETag         string `json:"ETag,omitempty"`
	IsLatest     bool   `json:"IsLatest,omitempty"`
	Key          string `json:"Key,omitempty"`
	LastModified string `json:"LastModified,omitempty"`
	Owner        Owner  `json:"Owner,omitempty"`
	Size         int64  `json:"Size,omitempty"`
	StorageClass string `json:"StorageClass,omitempty"`
	Type         string `json:"Type,omitempty"`
	VersionID    string `json:"VersionId,omitempty"`
}

type ListedObjectVersionV2 added in v2.1.3

type ListedObjectVersionV2 struct {
	Key           string
	LastModified  time.Time
	ETag          string
	IsLatest      bool
	Size          int64
	Owner         Owner
	StorageClass  enum.StorageClassType
	VersionID     string
	HashCrc64ecma uint64
}

type ListedOwner

type ListedOwner struct {
	ID string `json:"ID,omitempty"`
}

type ListedUpload

type ListedUpload struct {
	Key          string
	UploadID     string
	Owner        Owner
	StorageClass enum.StorageClassType
	Initiated    time.Time
}

type Logger added in v2.3.0

type Logger interface {
	Debug(args ...interface{})
	Info(args ...interface{})
	Warn(args ...interface{})
	Error(args ...interface{})
	Fatal(args ...interface{})
}

type Metadata added in v2.1.1

type Metadata interface {
	AllKeys() []string
	Get(key string) (string, bool)
	Range(f func(key, value string) bool)
}

type MultipartUploadedPart

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

type NoRetryClassifier

type NoRetryClassifier struct{}

func (NoRetryClassifier) Classify

func (classifier NoRetryClassifier) Classify(_ error) retryAction

Classify implements the classifier interface.

type ObjectAclGrant

type ObjectAclGrant struct {
	ACL              string `json:"ACL,omitempty"`
	GrantFullControl string `json:"GrantFullControl,omitempty"`
	GrantRead        string `json:"GrantRead,omitempty"`
	GrantReadAcp     string `json:"GrantReadAcp,omitempty"`
	// Deprecated: GrantWrite will be ignored
	GrantWrite    string `json:"GrantWrite,omitempty"`
	GrantWriteAcp string `json:"GrantWriteAcp,omitempty"`
}

type ObjectAclRules

type ObjectAclRules struct {
	Owner  Owner   `json:"Owner,omitempty"`
	Grants []Grant `json:"Grants,omitempty"`
}

type ObjectMeta

type ObjectMeta struct {
	ContentLength        int64             `json:"ContentLength,omitempty"`
	ContentType          string            `json:"ContentType,omitempty"`
	ContentMD5           string            `json:"ContentMD5,omitempty"`
	ContentLanguage      string            `json:"ContentLanguage,omitempty"`
	ContentEncoding      string            `json:"ContentEncoding,omitempty"`
	ContentDisposition   string            `json:"ContentDisposition,omitempty"`
	LastModified         string            `json:"LastModified,omitempty"`
	CacheControl         string            `json:"CacheControl,omitempty"`
	Expires              string            `json:"Expires,omitempty"`
	ETag                 string            `json:"ETag,omitempty"`
	VersionID            string            `json:"VersionId,omitempty"`
	DeleteMarker         bool              `json:"DeleteMarker,omitempty"`
	ObjectType           string            `json:"ObjectType,omitempty"` // "" or "Appendable"
	StorageClass         string            `json:"StorageClass,omitempty"`
	Restore              string            `json:"Restore,omitempty"`
	Metadata             map[string]string `json:"Metadata,omitempty"`
	Tag                  string            `json:"Tag,omitempty"`
	SSECustomerAlgorithm string            `json:"SSECustomerAlgorithm,omitempty"`
	SSECustomerKeyMD5    string            `json:"SSECustomerKeyMD5,omitempty"`
	CSType               string            `json:"CSType,omitempty"`
}

ObjectMeta object metadata

type ObjectMetaV2

type ObjectMetaV2 struct {
	ETag                    string
	LastModified            time.Time
	DeleteMarker            bool
	SSECAlgorithm           string
	SSECKeyMD5              string
	VersionID               string
	WebsiteRedirectLocation string
	ObjectType              string
	HashCrc64ecma           uint64
	StorageClass            enum.StorageClassType
	Meta                    Metadata
	ContentLength           int64
	ContentType             string
	CacheControl            string
	ContentDisposition      string
	ContentEncoding         string
	ContentLanguage         string
	Expires                 time.Time
}

type ObjectTobeDeleted

type ObjectTobeDeleted struct {
	Key       string `json:"Key,omitempty"`
	VersionID string `json:"VersionId,omitempty"`
}

type Option

type Option func(*requestBuilder)

func WithACL

func WithACL(acl string) Option

WithACL set X-Tos-Acl header

used in Bucket.PutObject Bucket.CreateMultipartUpload Bucket.AppendObject

func WithACLGrantFullControl

func WithACLGrantFullControl(grantFullControl string) Option

WithACLGrantFullControl X-Tos-Grant-Full-Control header

used in Bucket.PutObject Bucket.CreateMultipartUpload Bucket.AppendObject

func WithACLGrantRead

func WithACLGrantRead(grantRead string) Option

WithACLGrantRead set X-Tos-Grant-Read header

used in Bucket.PutObject Bucket.CreateMultipartUpload Bucket.AppendObject

func WithACLGrantReadAcp

func WithACLGrantReadAcp(grantReadAcp string) Option

WithACLGrantReadAcp set X-Tos-Grant-Read-Acp header

used in Bucket.PutObject Bucket.CreateMultipartUpload Bucket.AppendObject

func WithACLGrantWrite

func WithACLGrantWrite(grantWrite string) Option

WithACLGrantWrite set X-Tos-Grant-Write header

used in Bucket.PutObject Bucket.CreateMultipartUpload Bucket.AppendObject

func WithACLGrantWriteAcp

func WithACLGrantWriteAcp(grantWriteAcp string) Option

WithACLGrantWriteAcp set X-Tos-Grant-Write-Acp header

used in Bucket.PutObject Bucket.CreateMultipartUpload Bucket.AppendObject

func WithCacheControl

func WithCacheControl(cacheControl string) Option

WithCacheControl set Cache-Control header

used in Bucket.PutObject Bucket.AppendObject
  Bucket.CreateMultipartUpload Bucket.SetObjectMeta

func WithContentDisposition

func WithContentDisposition(contentDisposition string) Option

WithContentDisposition set Content-Disposition header

used in Bucket.PutObject Bucket.AppendObject Bucket.CreateMultipartUpload Bucket.SetObjectMeta

func WithContentEncoding

func WithContentEncoding(contentEncoding string) Option

WithContentEncoding set Content-Encoding header

used in Bucket.PutObject Bucket.AppendObject Bucket.CreateMultipartUpload Bucket.SetObjectMeta

func WithContentLanguage

func WithContentLanguage(contentLanguage string) Option

WithContentLanguage set Content-Language header

used in Bucket.PutObject Bucket.AppendObject Bucket.CreateMultipartUpload Bucket.SetObjectMeta

func WithContentLength

func WithContentLength(length int64) Option

WithContentLength set Content-Length header

used in Bucket.PutObject Bucket.AppendObject Bucket.UploadPart

If the length of the content is known, it is better to add this option when Put, Append or Upload.

func WithContentMD5

func WithContentMD5(contentMD5 string) Option

WithContentMD5 set Content-MD5 header

func WithContentSHA256

func WithContentSHA256(contentSHA256 string) Option

WithContentSHA256 set X-Tos-Content-Sha256 header

func WithContentType

func WithContentType(contentType string) Option

WithContentType set Content-Type header

used in Bucket.PutObject Bucket.AppendObject Bucket.CreateMultipartUpload Bucket.SetObjectMeta

func WithCopySourceIfMatch

func WithCopySourceIfMatch(ifMatch string) Option

WithCopySourceIfMatch set X-Tos-Copy-Source-If-Match header

used in Bucket.CopyObject Bucket.CopyObjectTo Bucket.CopyObjectFrom Bucket.UploadPartCopy

func WithCopySourceIfModifiedSince

func WithCopySourceIfModifiedSince(ifModifiedSince string) Option

WithCopySourceIfModifiedSince set X-Tos-Copy-Source-If-Modified-Since header

used in Bucket.CopyObject Bucket.CopyObjectTo Bucket.CopyObjectFrom Bucket.UploadPartCopy

func WithCopySourceIfNoneMatch

func WithCopySourceIfNoneMatch(ifNoneMatch string) Option

WithCopySourceIfNoneMatch set X-Tos-Copy-Source-If-None-Match

used in Bucket.CopyObject Bucket.CopyObjectTo Bucket.CopyObjectFrom Bucket.UploadPartCopy

func WithCopySourceIfUnmodifiedSince

func WithCopySourceIfUnmodifiedSince(ifUnmodifiedSince string) Option

WithCopySourceIfUnmodifiedSince set X-Tos-Copy-Source-If-Unmodified-Since header

used in Bucket.CopyObject Bucket.CopyObjectTo Bucket.CopyObjectFrom Bucket.UploadPartCopy

func WithExpires

func WithExpires(expires time.Time) Option

WithExpires set Expires header

used in Bucket.PutObject Bucket.AppendObject Bucket.CreateMultipartUpload Bucket.SetObjectMeta

func WithHeader

func WithHeader(key, value string) Option

WithHeader add request http header.

NOTICE: use it carefully.

func WithIfMatch

func WithIfMatch(ifMatch string) Option

WithIfMatch set If-Match header

func WithIfModifiedSince

func WithIfModifiedSince(since time.Time) Option

WithIfModifiedSince set If-Modified-Since header

used in Bucket.GetObject Bucket.HeadObject

func WithIfNoneMatch

func WithIfNoneMatch(ifNoneMatch string) Option

WithIfNoneMatch set If-None-Match header

func WithIfUnmodifiedSince

func WithIfUnmodifiedSince(since time.Time) Option

WithIfUnmodifiedSince set If-Unmodified-Since header

used in Bucket.GetObject Bucket.HeadObject

func WithMeta

func WithMeta(key, value string) Option

WithMeta set meta header

used in Bucket.PutObject Bucket.CreateMultipartUpload Bucket.AppendObject Bucket.SetObjectMeta

func WithMetadataDirective

func WithMetadataDirective(directive string) Option

WithMetadataDirective set X-Tos-Metadata-Directive header

used in Bucket.CopyObject Bucket.CopyObjectTo Bucket.CopyObjectFrom

func WithPerRequestSigner

func WithPerRequestSigner(signer Signer) Option

WithPerRequestSigner set Signer for a request

use this option when you need set request-level signature parameter(s). for example, use different ak and sk for each request.

if 'signer' set to nil, the request will not be signed.

func WithQuery

func WithQuery(key, value string) Option

WithQuery add request query parameter

NOTICE: use it carefully.

func WithRange

func WithRange(start, end int64) Option

WithRange set Range header

used in Bucket.GetObject Bucket.HeadObject

func WithServerSideEncryptionCustomer

func WithServerSideEncryptionCustomer(ssecAlgorithm, ssecKey, ssecKeyMD5 string) Option

WithServerSideEncryptionCustomer set server-side-encryption parameters

used in Bucket.PutObject Bucket.CreateMultipartUpload

func WithVersionID

func WithVersionID(versionID string) Option

WithVersionID set version parameter

used in Bucket.GetObject Bucket.HeadObject Bucket.DeleteObject
  Bucket.GetObjectAcl Bucket.SetObjectMeta
  Bucket.CopyObject Bucket.CopyObjectTo Bucket.CopyObjectFrom
  Client.PreSignedURL

func WithWebsiteRedirectLocation

func WithWebsiteRedirectLocation(redirectLocation string) Option

WithWebsiteRedirectLocation set X-Tos-Website-Redirect-Location header

type Owner

type Owner struct {
	ID          string `json:"ID,omitempty"`
	DisplayName string `json:"DisplayName,omitempty"`
}

type PreSignedURLInput

type PreSignedURLInput struct {
	HTTPMethod          enum.HttpMethodType
	Bucket              string
	Key                 string
	Expires             int64 // Expiration time in seconds, default 3600 seconds, max 7 days, range [1, 604800]
	Header              map[string]string
	Query               map[string]string
	AlternativeEndpoint string
}

type PreSignedURLOutput

type PreSignedURLOutput struct {
	SignedUrl    string            //  Pre-signed URL
	SignedHeader map[string]string // The actual header fields contained in the pre-signature
}

type Proxy

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

func NewProxy

func NewProxy(proxyHost string, proxyPort int) (*Proxy, error)

func (*Proxy) Url added in v2.3.0

func (p *Proxy) Url() *url.URL

func (*Proxy) WithAuth

func (p *Proxy) WithAuth(username string, password string)

type PutBucketCORSInput added in v2.1.10

type PutBucketCORSInput struct {
	Bucket    string     `json:"-"`
	CORSRules []CorsRule `json:"CORSRules,omitempty"`
}

type PutBucketCORSOutput added in v2.1.10

type PutBucketCORSOutput struct {
	RequestInfo `json:"-"`
}

type PutBucketPolicyOutput

type PutBucketPolicyOutput struct {
	RequestInfo `json:"-"`
}

type PutFetchTaskInput added in v2.1.8

type PutFetchTaskInput struct {
	URL           string `json:"URL,omitempty"`           // required
	Object        string `json:"Object,omitempty"`        // object key, required
	IgnoreSameKey bool   `json:"IgnoreSameKey,omitempty"` // optional, default value is false
	ContentMD5    string `json:"ContentMD5,omitempty"`    // hex-encoded md5, optional
}

type PutFetchTaskOutput added in v2.1.8

type PutFetchTaskOutput struct {
	RequestInfo `json:"-"`
	TaskID      string `json:"TaskId,omitempty"`
}

type PutObjectACLInput

type PutObjectACLInput struct {
	Bucket           string
	Key              string       // the object, required
	VersionID        string       `location:"query" locationName:"versionId"`                 // optional
	ACL              enum.ACLType `location:"header" locationName:"X-Tos-Acl"`                // optional
	GrantFullControl string       `location:"header" locationName:"X-Tos-Grant-Full-Control"` // optional
	GrantRead        string       `location:"header" locationName:"X-Tos-Grant-Read"`         // optional
	GrantReadAcp     string       `location:"header" locationName:"X-Tos-Grant-Read-Acp"`     // optional
	GrantWrite       string       `location:"header" locationName:"X-Tos-Grant-Write"`        // optional
	GrantWriteAcp    string       `location:"header" locationName:"X-Tos-Grant-Write-Acp"`    // optional
	Owner            Owner
	Grants           []GrantV2
}

type PutObjectACLOutput

type PutObjectACLOutput struct {
	PutObjectAclOutput
}

type PutObjectAclInput

type PutObjectAclInput struct {
	Key       string          `json:"Key,omitempty"`       // the object, required
	VersionID string          `json:"VersionId,omitempty"` // the version id of the object, optional
	AclGrant  *ObjectAclGrant `json:"AclGrant,omitempty"`  // set acl by header
	AclRules  *ObjectAclRules `json:"AclRules,omitempty"`  // set acl by rules
}

PutObjectAclInput AclGrant, AclRules can not set both.

type PutObjectAclOutput

type PutObjectAclOutput struct {
	RequestInfo `json:"-"`
}

type PutObjectBasicInput

type PutObjectBasicInput struct {
	Bucket             string
	Key                string
	ContentLength      int64        `location:"header" locationName:"Content-Length"`
	ContentMD5         string       `location:"header" locationName:"Content-MD5"`
	ContentSHA256      string       `location:"header" locationName:"X-Tos-Content-Sha256"`
	CacheControl       string       `location:"header" locationName:"Cache-Control"`
	ContentDisposition string       `location:"header" locationName:"Content-Disposition" encodeChinese:"true"`
	ContentEncoding    string       `location:"header" locationName:"Content-Encoding"`
	ContentLanguage    string       `location:"header" locationName:"Content-Language"`
	ContentType        string       `location:"header" locationName:"Content-Type"`
	Expires            time.Time    `location:"header" locationName:"Expires"`
	ACL                enum.ACLType `location:"header" locationName:"X-Tos-Acl"`

	GrantFullControl string `location:"header" locationName:"X-Tos-Grant-Full-Control"` // optional
	GrantRead        string `location:"header" locationName:"X-Tos-Grant-Read"`         // optional
	GrantReadAcp     string `location:"header" locationName:"X-Tos-Grant-Read-Acp"`     // optional
	GrantWriteAcp    string `location:"header" locationName:"X-Tos-Grant-Write-Acp"`    // optional

	WebsiteRedirectLocation string                `location:"header" locationName:"X-Tos-Website-Redirect-Location"`
	StorageClass            enum.StorageClassType `location:"header" locationName:"X-Tos-Storage-Class"`
	SSECAlgorithm           string                `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Algorithm"`
	SSECKey                 string                `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Key"`
	SSECKeyMD5              string                `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Key-MD5"`
	ServerSideEncryption    string                `location:"header" locationName:"X-Tos-Server-Side-Encryption"`
	Meta                    map[string]string     `location:"headers"`
	DataTransferListener    DataTransferListener
	RateLimiter             RateLimiter
}

type PutObjectFromFileInput

type PutObjectFromFileInput struct {
	PutObjectBasicInput
	FilePath string
}

type PutObjectFromFileOutput

type PutObjectFromFileOutput struct {
	PutObjectV2Output
}

type PutObjectOutput

type PutObjectOutput struct {
	RequestInfo          `json:"-"`
	ETag                 string `json:"ETag,omitempty"`
	VersionID            string `json:"VersionId,omitempty"`
	SSECustomerAlgorithm string `json:"SSECustomerAlgorithm,omitempty"`
	SSECustomerKeyMD5    string `json:"SSECustomerKeyMD5,omitempty"`
}

type PutObjectV2Input

type PutObjectV2Input struct {
	PutObjectBasicInput
	Content io.Reader
}

type PutObjectV2Output

type PutObjectV2Output struct {
	RequestInfo
	ETag          string
	SSECAlgorithm string
	SSECKeyMD5    string
	VersionID     string
	HashCrc64ecma uint64
}

type Range

type Range struct {
	Start int64
	End   int64
}

Range represents a range of an object

func (*Range) String

func (hr *Range) String() string

HTTP Range header

type RateLimiter

type RateLimiter interface {
	// Acquire try to get a token.
	// If ok, caller can read want bytes, else wait timeToWait and try again.
	Acquire(want int64) (ok bool, timeToWait time.Duration)
}

type ReadCloserWithLimiter

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

ReadCloserWithLimiter warp io.ReadCloser with DataTransferListener

func (ReadCloserWithLimiter) Close

func (r ReadCloserWithLimiter) Close() error

func (ReadCloserWithLimiter) Read

func (r ReadCloserWithLimiter) Read(p []byte) (n int, err error)

type Request

type Request struct {
	Scheme        string
	Method        string
	Host          string
	Path          string
	ContentLength *int64
	Content       io.Reader
	Query         url.Values
	Header        http.Header
}

func (*Request) URL

func (req *Request) URL() string

type RequestInfo

type RequestInfo struct {
	RequestID  string
	ID2        string
	StatusCode int
	Header     http.Header
}

type Response

type Response struct {
	StatusCode    int
	ContentLength int64
	Header        http.Header
	Body          io.ReadCloser
}

func (*Response) Close

func (r *Response) Close() error

func (*Response) RequestInfo

func (r *Response) RequestInfo() RequestInfo

type SSEHeaders

type SSEHeaders struct {
	SSECAlgorithm        string `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Algorithm"`
	SSECKey              string `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Key"`
	SSECKeyMD5           string `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Key-MD5"`
	ServerSideEncryption string `location:"header" locationName:"X-Tos-Server-Side-Encryption"`
}

type SerializeError

type SerializeError struct {
	RequestID string `json:"RequestId,omitempty"`
	Message   string `json:"Message,omitempty"`
}

func (*SerializeError) Error

func (se *SerializeError) Error() string

type ServerErrorClassifier

type ServerErrorClassifier struct{}

ServerErrorClassifier classify errors returned by POST method. If the error is nil, it returns NoRetry; if the error can be interpreted as TosServerError and its StatusCode is 5xx, it returns Retry; otherwise, it returns NoRetry.

func (ServerErrorClassifier) Classify

func (classifier ServerErrorClassifier) Classify(err error) retryAction

Classify implements the classifier interface.

type SetObjectMetaInput

type SetObjectMetaInput struct {
	Bucket    string
	Key       string
	VersionID string

	CacheControl       string    `location:"header" locationName:"Cache-Control"`
	ContentDisposition string    `location:"header" locationName:"Content-Disposition"`
	ContentEncoding    string    `location:"header" locationName:"Content-Encoding"`
	ContentLanguage    string    `location:"header" locationName:"Content-Language"`
	ContentType        string    `location:"header" locationName:"Content-Type"`
	Expires            time.Time `location:"header" locationName:"Expires"`

	Meta map[string]string `location:"headers"`
}

type SetObjectMetaOutput

type SetObjectMetaOutput struct {
	RequestInfo `json:"-"`
}

type SignV4

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

func NewSignV4

func NewSignV4(credentials Credentials, region string) *SignV4

NewSignV4 create SignV4 use WithSignKey to set self-defined sign-key generator use WithSignLogger to set logger

func (*SignV4) SignHeader

func (sv *SignV4) SignHeader(req *Request) http.Header

func (*SignV4) SignQuery

func (sv *SignV4) SignQuery(req *Request, ttl time.Duration) url.Values

func (*SignV4) WithSignLogger added in v2.2.0

func (sv *SignV4) WithSignLogger(logger Logger)

func (*SignV4) WithSigningKey

func (sv *SignV4) WithSigningKey(signingKey func(*SigningKeyInfo) []byte)

WithSigningKey for self-defined sign-key generator

type SignV4Option added in v2.2.0

type SignV4Option func(*SignV4)

type Signer

type Signer interface {
	SignHeader(req *Request) http.Header

	SignQuery(req *Request, ttl time.Duration) url.Values
}

type SigningKeyInfo

type SigningKeyInfo struct {
	Date       string
	Region     string
	Credential *Credential
}

type StaticCredentials

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

StaticCredentials Credentials with static access-key and secret-key

func NewStaticCredentials

func NewStaticCredentials(accessKeyID, accessKeySecret string) *StaticCredentials

NewStaticCredentials Credentials with static access-key and secret-key

use StaticCredentials.WithSecurityToken to set security-token

you can use it as:

client, err := tos.NewClient(endpoint, tos.WithCredentials(tos.NewStaticCredentials(accessKey, secretKey)))
// do something more

And you can use tos.WithPerRequestSigner set the 'Signer' for each request.

func (*StaticCredentials) Credential

func (sc *StaticCredentials) Credential() Credential

func (*StaticCredentials) WithSecurityToken

func (sc *StaticCredentials) WithSecurityToken(securityToken string)

WithSecurityToken set security-token

type StatusCodeClassifier

type StatusCodeClassifier struct{}

StatusCodeClassifier classifies Errors. If the error is nil, it returns NoRetry; if the error is TimeoutException or can be interpreted as TosServerError, and the StatusCode is 5xx or 429, it returns Retry; otherwise, it returns NoRetry.

func (StatusCodeClassifier) Classify

func (classifier StatusCodeClassifier) Classify(err error) retryAction

Classify implements the classifier interface.

type TimeoutConn

type TimeoutConn struct {
	net.Conn
	// contains filtered or unexported fields
}

func NewTimeoutConn

func NewTimeoutConn(conn net.Conn, readTimeout, writeTimeout time.Duration) *TimeoutConn

func (*TimeoutConn) Read

func (tc *TimeoutConn) Read(b []byte) (n int, err error)

func (*TimeoutConn) Write

func (tc *TimeoutConn) Write(b []byte) (n int, err error)

type TimeoutDialer

type TimeoutDialer struct {
	net.Dialer

	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	// contains filtered or unexported fields
}

func (*TimeoutDialer) DialContext

func (d *TimeoutDialer) DialContext(ctx context.Context, network, address string) (net.Conn, error)

type TosClientError

type TosClientError struct {
	TosError
	Cause error
}

type TosError

type TosError struct {
	Message string
}

func (*TosError) Error

func (e *TosError) Error() string

type TosServerError

type TosServerError struct {
	TosError    `json:"TosError"`
	RequestInfo `json:"RequestInfo"`
	Code        string `json:"Code,omitempty"`
	HostID      string `json:"HostID,omitempty"`
	Resource    string `json:"Resource,omitempty"`
}

服务端错误定义参考:https://www.volcengine.com/docs/6349/74874

type Transport

type Transport interface {
	RoundTrip(context.Context, *Request) (*Response, error)
}

type TransportConfig

type TransportConfig struct {

	// MaxIdleConns same as http.Transport MaxIdleConns. Default is 1024.
	MaxIdleConns int

	// MaxIdleConnsPerHost same as http.Transport MaxIdleConnsPerHost. Default is 1024.
	MaxIdleConnsPerHost int

	// MaxConnsPerHost same as http.Transport MaxConnsPerHost. Default is no limit.
	MaxConnsPerHost int

	// RequestTimeout same as http.Client Timeout
	// Deprecated: use ReadTimeout or WriteTimeout instead
	RequestTimeout time.Duration

	// DialTimeout same as net.Dialer Timeout
	DialTimeout time.Duration

	// KeepAlive same as net.Dialer KeepAlive
	KeepAlive time.Duration

	// IdleConnTimeout same as http.Transport IdleConnTimeout
	IdleConnTimeout time.Duration

	// TLSHandshakeTimeout same as http.Transport TLSHandshakeTimeout
	TLSHandshakeTimeout time.Duration

	// ResponseHeaderTimeout same as http.Transport ResponseHeaderTimeout
	ResponseHeaderTimeout time.Duration

	// ExpectContinueTimeout same as http.Transport ExpectContinueTimeout
	ExpectContinueTimeout time.Duration

	// ReadTimeout see net.Conn SetReadDeadline
	ReadTimeout time.Duration

	// WriteTimeout set net.Conn SetWriteDeadline
	WriteTimeout time.Duration

	// InsecureSkipVerify set tls.Config InsecureSkipVerify
	InsecureSkipVerify bool

	// DNSCacheTime Set Dns Cache Time.
	DNSCacheTime time.Duration

	// Proxy Set http proxy for http client.
	Proxy *Proxy
}

func DefaultTransportConfig

func DefaultTransportConfig() TransportConfig

type UnexpectedStatusCodeError

type UnexpectedStatusCodeError struct {
	StatusCode    int    `json:"StatusCode,omitempty"`
	ExpectedCodes []int  `json:"ExpectedCodes,omitempty"`
	RequestID     string `json:"RequestId,omitempty"`
	// contains filtered or unexported fields
}

func NewUnexpectedStatusCodeError

func NewUnexpectedStatusCodeError(statusCode int, expectedCode int, expectedCodes ...int) *UnexpectedStatusCodeError

func (*UnexpectedStatusCodeError) Error

func (us *UnexpectedStatusCodeError) Error() string

func (*UnexpectedStatusCodeError) GoString

func (us *UnexpectedStatusCodeError) GoString() string

func (*UnexpectedStatusCodeError) WithRequestID

func (us *UnexpectedStatusCodeError) WithRequestID(requestID string) *UnexpectedStatusCodeError

type UploadCommonPrefix

type UploadCommonPrefix struct {
	Prefix string `json:"Prefix"`
}

type UploadEvent

type UploadEvent struct {
	Type           enum.UploadEventType
	Err            error // failed, aborted 事件发生时不为空
	Bucket         string
	Key            string
	UploadID       *string
	CheckpointFile *string // 断点续传文件全路径
	// upload part 相关事件发生时有值
	UploadPartInfo *UploadPartInfo
}

type UploadEventListener

type UploadEventListener interface {
	EventChange(event *UploadEvent)
}

type UploadFileInput

type UploadFileInput struct {
	CreateMultipartUploadV2Input

	FilePath             string
	PartSize             int64
	TaskNum              int
	EnableCheckpoint     bool
	CheckpointFile       string
	DataTransferListener DataTransferListener
	UploadEventListener  UploadEventListener
	RateLimiter          RateLimiter
	// cancelHook 支持取消断点续传任务
	CancelHook CancelHook
}

type UploadFileOutput

type UploadFileOutput struct {
	RequestInfo
	Bucket        string
	Key           string
	UploadID      string
	ETag          string
	Location      string
	VersionID     string
	HashCrc64ecma uint64
	SSECAlgorithm string
	SSECKeyMD5    string
	EncodingType  string
}

type UploadInfo

type UploadInfo struct {
	Key          string `json:"Key,omitempty"`
	UploadId     string `json:"UploadId,omitempty"`
	Owner        Owner  `json:"Owner,omitempty"`
	StorageClass string `json:"StorageClass,omitempty"`
	Initiated    string `json:"Initiated,omitempty"`
}

type UploadPartBasicInput

type UploadPartBasicInput struct {
	Bucket     string
	Key        string
	UploadID   string `location:"query" locationName:"uploadId"`
	PartNumber int    `location:"query" locationName:"partNumber"`

	ContentMD5 string `location:"header" locationName:"Content-MD5"`

	SSECAlgorithm        string `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Algorithm"`
	SSECKey              string `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Key"`
	SSECKeyMD5           string `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Key-MD5"`
	ServerSideEncryption string `location:"header" locationName:"X-Tos-Server-Side-Encryption"`

	DataTransferListener DataTransferListener
	RateLimiter          RateLimiter
}

type UploadPartCopyInput

type UploadPartCopyInput struct {
	UploadID        string `json:"UploadId,omitempty"`
	DestinationKey  string `json:"DestinationKey,omitempty"`
	SourceBucket    string `json:"SourceBucket,omitempty"`
	SourceKey       string `json:"SourceKey,omitempty"`
	SourceVersionID string `json:"SourceVersionId,omitempty"` // optional
	StartOffset     *int64 `json:"StartOffset,omitempty"`     // optional
	PartSize        *int64 `json:"PartSize,omitempty"`        // optional
	PartNumber      int    `json:"PartNumber,omitempty"`
}

type UploadPartCopyOutput

type UploadPartCopyOutput struct {
	RequestInfo     `json:"-"`
	VersionID       string `json:"VersionId,omitempty"`
	SourceVersionID string `json:"SourceVersionId,omitempty"`
	PartNumber      int    `json:"PartNumber,omitempty"`
	ETag            string `json:"ETag,omitempty"`
	LastModified    string `json:"LastModified,omitempty"`
}

type UploadPartCopyV2Input

type UploadPartCopyV2Input struct {
	Bucket     string
	Key        string
	UploadID   string `location:"query" locationName:"uploadId"`
	PartNumber int    `location:"query" locationName:"partNumber"`

	SrcBucket            string
	SrcKey               string
	SrcVersionID         string `location:"query" locationName:"versionId"`
	CopySourceRangeStart int64
	CopySourceRangeEnd   int64

	CopySourceIfMatch           string    `location:"header" locationName:"X-Tos-Copy-Source-If-Match"`
	CopySourceIfModifiedSince   time.Time `location:"header" locationName:"X-Tos-Copy-Source-If-Modified-Since"`
	CopySourceIfNoneMatch       string    `location:"header" locationName:"X-Tos-Copy-Source-If-None-Match"`
	CopySourceIfUnmodifiedSince time.Time `location:"header" locationName:"X-Tos-Copy-Source-If-Unmodified-Since"`

	CopySourceSSECAlgorithm string `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Algorithm"`
	CopySourceSSECKey       string `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Key"`
	CopySourceSSECKeyMD5    string `location:"header" locationName:"X-Tos-Server-Side-Encryption-Customer-Key-MD5"`
}

type UploadPartCopyV2Output

type UploadPartCopyV2Output struct {
	RequestInfo
	PartNumber          int
	ETag                string
	LastModified        time.Time
	CopySourceVersionID string
}

type UploadPartFromFileInput

type UploadPartFromFileInput struct {
	UploadPartBasicInput
	FilePath string
	Offset   uint64 // 当前分段在文件中的起始位置
	PartSize int64  // 当前分段长度,该字段等同于 Content-Length 头域
}

type UploadPartFromFileOutput

type UploadPartFromFileOutput struct {
	UploadPartV2Output
}

type UploadPartInfo

type UploadPartInfo struct {
	PartNumber int
	PartSize   int64
	Offset     int64
	// upload part succeed 事件发生时有值
	ETag          *string
	HashCrc64ecma *uint64
}

UploadPartInfo is returned when UploadEvent occur

type UploadPartInput

type UploadPartInput struct {
	Key        string    `json:"Key,omitempty"`
	UploadID   string    `json:"UploadId,omitempty"`
	PartNumber int       `json:"PartNumber,omitempty"`
	Content    io.Reader `json:"-"`
}

type UploadPartOutput

type UploadPartOutput struct {
	RequestInfo          `json:"-"`
	PartNumber           int    `json:"PartNumber,omitempty"`
	ETag                 string `json:"ETag,omitempty"`
	SSECustomerAlgorithm string `json:"SSECustomerAlgorithm,omitempty"`
	SSECustomerKeyMD5    string `json:"SSECustomerKeyMD5,omitempty"`
}

type UploadPartV2Input

type UploadPartV2Input struct {
	UploadPartBasicInput
	Content       io.Reader
	ContentLength int64 `location:"header" locationName:"Content-Length"`
}

type UploadPartV2Output

type UploadPartV2Output struct {
	RequestInfo
	PartNumber    int
	ETag          string
	SSECAlgorithm string
	SSECKeyMD5    string
	HashCrc64ecma uint64
}

type UploadedPart

type UploadedPart struct {
	PartNumber   int32  `json:"PartNumber,omitempty"`   // Part编号
	ETag         string `json:"ETag,omitempty"`         // ETag
	LastModified string `json:"LastModified,omitempty"` // 最后一次修改时间
	Size         int64  `json:"Size,omitempty"`         // Part大小
}

type UploadedPartV2

type UploadedPartV2 struct {
	PartNumber   int       `json:"PartNumber,omitempty"`   // Part编号
	ETag         string    `json:"ETag,omitempty"`         // ETag
	LastModified time.Time `json:"LastModified,omitempty"` // 最后一次修改时间
	Size         int64     `json:"Size,omitempty"`         // Part大小
}

type WithoutSecretKeyCredentials

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

WithoutSecretKeyCredentials Credentials with static access-key and no secret-key

If you don't want to use secret-key directly, but use signed-key, you can use it as:

signer := tos.NewSignV4(tos.NewWithoutSecretKeyCredentials(accessKey), region)
signer.WithSigningKey(func(*SigningKeyInfo) []byte { return signingKey})
client, err := tos.NewClient(endpoint, tos.WithSigner(signer))
// do something more

And you can use tos.WithPerRequestSigner set the 'Signer' for each request.

func NewWithoutSecretKeyCredentials

func NewWithoutSecretKeyCredentials(accessKeyID string) *WithoutSecretKeyCredentials

func (*WithoutSecretKeyCredentials) Credential

func (sc *WithoutSecretKeyCredentials) Credential() Credential

func (*WithoutSecretKeyCredentials) WithSecurityToken

func (sc *WithoutSecretKeyCredentials) WithSecurityToken(securityToken string)

WithSecurityToken set security-token

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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