Documentation ¶
Index ¶
- Constants
- Variables
- func CanonicalizeETag(etag string) string
- func CopySeekableBody(dst io.Writer, src io.ReadSeeker) (int64, error)
- func EncodePath(pathName string) string
- func GetRegionFromURL(endpointURL url.URL) string
- func IsAliyunOSSEndpoint(endpointURL url.URL) bool
- func IsAmazonEndpoint(endpointURL url.URL) bool
- func IsAmazonFIPSGovCloudEndpoint(endpointURL url.URL) bool
- func IsAmazonGovCloudEndpoint(endpointURL url.URL) bool
- func IsQiniuKodoEndpoint(endpointURL url.URL) bool
- func IsReaderSeekable(r io.Reader) bool
- func IsVirtualHostSupported(endpointURL url.URL, bucketName string) bool
- func PreSignV4(req http.Request, accessKeyID, secretAccessKey, sessionToken, location string, ...) *http.Request
- func QueryEncode(v url.Values) string
- func SeekerLen(s io.Seeker) (int64, error)
- func SignServiceV4(req http.Request, body io.ReadSeeker, ...) *http.Request
- func SignV4(req http.Request, accessKeyID, secretAccessKey, sessionToken, location string) *http.Request
- func StreamingChunkSignV4(req *http.Request, accessKeyID, secretAccessKey, sessionToken, region string, ...) *http.Request
- func StreamingSignV4(req *http.Request, accessKeyID, secretAccessKey, sessionToken, region string, ...) *http.Request
- func TagDecode(ctag string) map[string]string
- func TagEncode(tags map[string]string) string
- func UTCNow() time.Time
- func UnescapePath(p string) (string, error)
- func XmlDecoder(body io.Reader, v interface{}, size int64) error
- type Client
- type ClientOption
- type CommonPrefix
- type CompleteMultipartUpload
- type CompletePart
- type CompletedParts
- type CopySrcOptions
- type Credentials
- type ErrorResponse
- type GetObjectOptions
- func (o GetObjectOptions) Header() http.Header
- func (o *GetObjectOptions) Set(key, value string)
- func (o *GetObjectOptions) SetMatchETag(etag string) error
- func (o *GetObjectOptions) SetMatchETagExcept(etag string) error
- func (o *GetObjectOptions) SetModified(modTime time.Time) error
- func (o *GetObjectOptions) SetRange(start, end int64) error
- func (o *GetObjectOptions) SetUnmodified(modTime time.Time) error
- type HTTPRangeSpec
- type Hasher
- type InitiateMultipartUploadResult
- type ListBucketResult
- type ListBucketV2Result
- type ListMultipartUploadsResult
- type ListObjectPartsResult
- type MultiCloser
- type ObjectInfo
- type ObjectMultipartInfo
- type ObjectPart
- type Owner
- type Provider
- type PutObjectOptions
- type ReaderSeekerCloser
- func (r ReaderSeekerCloser) Close() error
- func (r ReaderSeekerCloser) GetLen() (int64, error)
- func (r ReaderSeekerCloser) HasLen() (int, bool)
- func (r ReaderSeekerCloser) IsSeeker() bool
- func (r ReaderSeekerCloser) Read(p []byte) (int, error)
- func (r ReaderSeekerCloser) Seek(offset int64, whence int) (int64, error)
- type RemoveObjectOptions
- type StatObjectOptions
- type Static
- type StreamingChunkReader
- type StreamingReader
- type StringMap
- type UploadInfo
- type Value
- type WriteAtBuffer
Constants ¶
const ( MaxJitter = 1.0 NoJitter = 0.0 )
const ( ServiceTypeS3 = "s3" ServiceTypeSTS = "sts" )
const ( KB MB GB TB PB EB )
Variables ¶
var ( MaxRetry = 10 DefaultRetryUnit = 200 * time.Millisecond DefaultRetryCap = time.Second )
var DefaultTransport = func(secure bool) (*http.Transport, error) { tr := &http.Transport{ Proxy: http.ProxyFromEnvironment, DialContext: (&net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second, }).DialContext, MaxIdleConns: 256, MaxIdleConnsPerHost: 16, ResponseHeaderTimeout: time.Minute, IdleConnTimeout: time.Minute, TLSHandshakeTimeout: 10 * time.Second, ExpectContinueTimeout: 10 * time.Second, DisableCompression: true, } if secure { tr.TLSClientConfig = &tls.Config{ MinVersion: tls.VersionTLS12, } } return tr, nil }
Functions ¶
func CanonicalizeETag ¶
func CopySeekableBody ¶
func EncodePath ¶
func GetRegionFromURL ¶
func IsAliyunOSSEndpoint ¶
IsAliyunOSSEndpoint - Match if it is exactly Aliyun OSS endpoint.
func IsAmazonEndpoint ¶
IsAmazonEndpoint - Match if it is exactly Amazon S3 endpoint.
func IsAmazonGovCloudEndpoint ¶
IsAmazonGovCloudEndpoint - Match if it is exactly Amazon S3 GovCloud endpoint.
func IsQiniuKodoEndpoint ¶
IsQiniuKodoEndpoint - Match if it is exactly qiniu KODO endpoint.
func IsReaderSeekable ¶
func IsVirtualHostSupported ¶
func QueryEncode ¶
func SignServiceV4 ¶
func SignV4 ¶
func SignV4(req http.Request, accessKeyID, secretAccessKey, sessionToken, location string) *http.Request
http://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html.
func StreamingChunkSignV4 ¶
func StreamingChunkSignV4(req *http.Request, accessKeyID, secretAccessKey, sessionToken, region string, dataLen int64, reqTime time.Time) *http.Request
StreamingSignV4 - provides chunked upload signatureV4 support by implementing io.Reader.
func StreamingSignV4 ¶
func UnescapePath ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(endpoint string, creds *Credentials, opts ...ClientOption) (*Client, error)
func (*Client) EndpointURL ¶
type ClientOption ¶
type ClientOption interface {
// contains filtered or unexported methods
}
type CommonPrefix ¶
type CommonPrefix struct {
Prefix string
}
type CompleteMultipartUpload ¶
type CompleteMultipartUpload struct {
Parts []CompletePart `xml:"Part"`
}
type CompletePart ¶
type CompletedParts ¶
type CompletedParts []CompletePart
func (CompletedParts) Len ¶
func (a CompletedParts) Len() int
func (CompletedParts) Less ¶
func (a CompletedParts) Less(i, j int) bool
func (CompletedParts) Swap ¶
func (a CompletedParts) Swap(i, j int)
type CopySrcOptions ¶
type Credentials ¶
func NewCredentials ¶
func NewCredentials(provider Provider) *Credentials
func NewStatic ¶
func NewStatic(id, secret, token string) *Credentials
func NewStaticV4 ¶
func NewStaticV4(id, secret, token string) *Credentials
func (*Credentials) Expire ¶
func (c *Credentials) Expire()
func (*Credentials) Get ¶
func (c *Credentials) Get() (Value, error)
func (*Credentials) IsExpired ¶
func (c *Credentials) IsExpired() bool
type ErrorResponse ¶
type ErrorResponse struct { XMLName xml.Name `xml:"Error" json:"-"` Code string Message string BucketName string Key string RequestID string `xml:"RequestId"` HostID string `xml:"HostId"` Region string Server string StatusCode int `xml:"-" json:"-"` }
golang http API (https://github.com/golang/go/issues/29768)
func ToErrorResponse ¶
func ToErrorResponse(err error) ErrorResponse
type GetObjectOptions ¶
type GetObjectOptions struct { VersionID string Decryption bool // contains filtered or unexported fields }
during GET requests.
func (GetObjectOptions) Header ¶
func (o GetObjectOptions) Header() http.Header
func (*GetObjectOptions) Set ¶
func (o *GetObjectOptions) Set(key, value string)
func (*GetObjectOptions) SetMatchETag ¶
func (o *GetObjectOptions) SetMatchETag(etag string) error
SetMatchETag - set match etag.
func (*GetObjectOptions) SetMatchETagExcept ¶
func (o *GetObjectOptions) SetMatchETagExcept(etag string) error
func (*GetObjectOptions) SetModified ¶
func (o *GetObjectOptions) SetModified(modTime time.Time) error
func (*GetObjectOptions) SetRange ¶
func (o *GetObjectOptions) SetRange(start, end int64) error
See https://tools.ietf.org/html/rfc7233#section-3.1 for reference.
func (*GetObjectOptions) SetUnmodified ¶
func (o *GetObjectOptions) SetUnmodified(modTime time.Time) error
type HTTPRangeSpec ¶
func ParseRequestRangeSpec ¶
func ParseRequestRangeSpec(rangeString string) (hrange *HTTPRangeSpec, err error)
func (*HTTPRangeSpec) GetLength ¶
func (h *HTTPRangeSpec) GetLength(resourceSize int64) (rangeLength int64, err error)
func (*HTTPRangeSpec) GetOffsetLength ¶
func (h *HTTPRangeSpec) GetOffsetLength(resourceSize int64) (start, length int64, err error)
func (*HTTPRangeSpec) String ¶
func (h *HTTPRangeSpec) String(resourceSize int64) string
type ListBucketResult ¶
type ListBucketResult struct { CommonPrefixes []CommonPrefix Contents []ObjectInfo Delimiter string EncodingType string IsTruncated bool Marker string MaxKeys int64 Name string NextMarker string Prefix string }
type ListBucketV2Result ¶
type ListMultipartUploadsResult ¶
type ListMultipartUploadsResult struct { Bucket string KeyMarker string UploadIDMarker string `xml:"UploadIdMarker"` NextKeyMarker string NextUploadIDMarker string `xml:"NextUploadIdMarker"` EncodingType string MaxUploads int64 IsTruncated bool Uploads []ObjectMultipartInfo `xml:"Upload"` Prefix string Delimiter string // A response can contain CommonPrefixes only if you specify a delimiter. CommonPrefixes []CommonPrefix }
type ListObjectPartsResult ¶
type ListObjectPartsResult struct { Bucket string Key string UploadID string `xml:"UploadId"` Initiator initiator Owner owner StorageClass string PartNumberMarker int NextPartNumberMarker int MaxParts int // Indicates whether the returned list of parts is truncated. IsTruncated bool ObjectParts []ObjectPart `xml:"Part"` EncodingType string }
type MultiCloser ¶
func (MultiCloser) Close ¶
func (m MultiCloser) Close() error
type ObjectInfo ¶
type ObjectInfo struct { // An ETag is optionally set to md5sum of an object. In case of multipart objects, // ETag is of the form MD5SUM-N where MD5SUM is md5sum of all individual md5sums of // each parts concatenated into one string. ETag string `json:"etag"` Key string `json:"name"` // Name of the object LastModified time.Time `json:"lastModified"` // Date and time the object was last modified. Size int64 `json:"size"` // Size in bytes of the object. ContentType string `json:"contentType"` // A standard MIME type describing the format of the object data. Expires time.Time `json:"expires"` // The date and time at which the object is no longer able to be cached. // Collection of additional metadata on the object. // eg: x-amz-meta-*, content-encoding etc. Metadata http.Header `json:"metadata" xml:"-"` // x-amz-meta-* headers stripped "x-amz-meta-" prefix containing the first value. UserMetadata StringMap `json:"userMetadata"` // x-amz-tagging values in their k/v values. UserTags map[string]string `json:"userTags"` // x-amz-tagging-count value UserTagCount int // Owner name. Owner Owner // ACL grant. Grant []struct { Grantee struct { ID string `xml:"ID"` DisplayName string `xml:"DisplayName"` URI string `xml:"URI"` } `xml:"Grantee"` Permission string `xml:"Permission"` } `xml:"Grant"` // The class of storage used to store the object. StorageClass string `json:"storageClass"` // Versioning related information IsLatest bool IsDeleteMarker bool VersionID string `xml:"VersionId"` // x-amz-replication-status value is either in one of the following states // - COMPLETE // - PENDING // - FAILED // - REPLICA (on the destination) ReplicationStatus string `xml:"ReplicationStatus"` // Lifecycle expiry-date and ruleID associated with the expiry // not to be confused with `Expires` HTTP header. Expiration time.Time ExpirationRuleID string // Error Err error `json:"-"` }
func ToObjectInfo ¶
type ObjectMultipartInfo ¶
type ObjectMultipartInfo struct { // Date and time at which the multipart upload was initiated. Initiated time.Time `type:"timestamp" timestampFormat:"iso8601"` Initiator initiator Owner owner // The type of storage to use for the object. Defaults to 'STANDARD'. StorageClass string // Key of the object for which the multipart upload was initiated. Key string // Size in bytes of the object. Size int64 // Upload ID that identifies the multipart upload. UploadID string `xml:"UploadId"` // Error Err error }
type ObjectPart ¶
type PutObjectOptions ¶
type PutObjectOptions struct { UserMetadata map[string]string UserTags map[string]string Progress io.Reader ContentType string ContentEncoding string ContentDisposition string ContentLanguage string CacheControl string RetainUntilDate time.Time NumThreads uint StorageClass string WebsiteRedirectLocation string PartSize uint64 SendContentMd5 bool DisableMultipart bool }
func (PutObjectOptions) Header ¶
func (opts PutObjectOptions) Header() (header http.Header)
Header - constructs the headers from metadata entered by user in PutObjectOptions struct
type ReaderSeekerCloser ¶
type ReaderSeekerCloser struct {
// contains filtered or unexported fields
}
func ReadSeekCloser ¶
func ReadSeekCloser(r io.Reader) ReaderSeekerCloser
func (ReaderSeekerCloser) Close ¶
func (r ReaderSeekerCloser) Close() error
func (ReaderSeekerCloser) GetLen ¶
func (r ReaderSeekerCloser) GetLen() (int64, error)
func (ReaderSeekerCloser) HasLen ¶
func (r ReaderSeekerCloser) HasLen() (int, bool)
func (ReaderSeekerCloser) IsSeeker ¶
func (r ReaderSeekerCloser) IsSeeker() bool
type RemoveObjectOptions ¶
type StatObjectOptions ¶
type StatObjectOptions = GetObjectOptions
type StreamingChunkReader ¶
type StreamingChunkReader struct {
// contains filtered or unexported fields
}
func (*StreamingChunkReader) Close ¶
func (s *StreamingChunkReader) Close() error
type StreamingReader ¶
type StreamingReader struct {
// contains filtered or unexported fields
}
type StringMap ¶
func (*StringMap) UnmarshalXML ¶
type UploadInfo ¶
type WriteAtBuffer ¶
type WriteAtBuffer struct { GrowthCoeff float64 // contains filtered or unexported fields }
func NewWriteAtBuffer ¶
func NewWriteAtBuffer(buf []byte) *WriteAtBuffer
func (*WriteAtBuffer) Bytes ¶
func (b *WriteAtBuffer) Bytes() []byte