Documentation ¶
Index ¶
- Constants
- Variables
- func CreateRandomString() string
- func CreateSignature(stringToSignature, accessKeySecret string) string
- func Encode(v url.Values) string
- func GetGMTime() string
- func GetNowNanoSec() int64
- func GetNowSec() int64
- func GetURIPath(u *url.URL) string
- func IsNotFoundError(err error) bool
- func MakeSha1(data string) string
- func NewRequest(method, urlStr string) (*request, error)
- type Bucket
- func (b *Bucket) DeleteObject(key string) error
- func (b *Bucket) DoGetObject(key string, options ...Option) (*GetObjectResult, error)
- func (b *Bucket) Exists() (bool, error)
- func (b *Bucket) GetObject(key string, options ...Option) (io.ReadCloser, error)
- func (b *Bucket) GetObjectMeta(key string) (http.Header, error)
- func (b *Bucket) ListObjects(options ...Option) (*ListObjectsResult, error)
- func (b *Bucket) PutObject(key string, body interface{}, options ...Option) error
- type Client
- type Error
- type GetObjectResult
- type ListObjectsResult
- type ObjectProperties
- type Option
- type Owner
Constants ¶
const ( HTTPHeaderAcceptEncoding string = "Accept-Encoding" HTTPHeaderAuthorization = "Authorization" HTTPHeaderCacheControl = "Cache-Control" HTTPHeaderContentDisposition = "Content-Disposition" HTTPHeaderContentEncoding = "Content-Encoding" HTTPHeaderContentLength = "Content-Length" HTTPHeaderContentMD5 = "Content-MD5" HTTPHeaderContentType = "Content-Type" HTTPHeaderContentLanguage = "Content-Language" HTTPHeaderDate = "Date" HTTPHeaderEtag = "ETag" HTTPHeaderExpires = "Expires" HTTPHeaderHost = "Host" HTTPHeaderLastModified = "Last-Modified" HTTPHeaderRange = "Range" HTTPHeaderLocation = "Location" HTTPHeaderOrigin = "Origin" HTTPHeaderServer = "Server" HTTPHeaderUserAgent = "User-Agent" HTTPHeaderIfModifiedSince = "If-Modified-Since" HTTPHeaderIfUnmodifiedSince = "If-Unmodified-Since" HTTPHeaderIfMatch = "If-Match" HTTPHeaderIfNoneMatch = "If-None-Match" HTTPHeaderOssACL = "X-Oss-Acl" HTTPHeaderOssMetaPrefix = "X-Oss-Meta-" HTTPHeaderOssObjectACL = "X-Oss-Object-Acl" HTTPHeaderOssSecurityToken = "X-Oss-Security-Token" HTTPHeaderOssServerSideEncryption = "X-Oss-Server-Side-Encryption" HTTPHeaderOssCopySource = "X-Oss-Copy-Source" HTTPHeaderOssCopySourceRange = "X-Oss-Copy-Source-Range" HTTPHeaderOssCopySourceIfMatch = "X-Oss-Copy-Source-If-Match" HTTPHeaderOssCopySourceIfNoneMatch = "X-Oss-Copy-Source-If-None-Match" HTTPHeaderOssCopySourceIfModifiedSince = "X-Oss-Copy-Source-If-Modified-Since" HTTPHeaderOssCopySourceIfUnmodifiedSince = "X-Oss-Copy-Source-If-Unmodified-Since" HTTPHeaderOssMetadataDirective = "X-Oss-Metadata-Directive" HTTPHeaderOssNextAppendPosition = "X-Oss-Next-Append-Position" HTTPHeaderOssRequestID = "X-Oss-Request-Id" HTTPHeaderOssCRC64 = "X-Oss-Hash-Crc64ecma" HTTPHeaderOssSymlinkTarget = "X-Oss-Symlink-Target" )
HTTP headers
const ( QSignAlgorithm = "q-sign-algorithm" QAK = "q-ak" QSignTime = "q-sign-time" QKeyTime = "q-key-time" QHeaderList = "q-header-list" QUrlParamList = "q-url-param-list" QSign = "q-signature" SignAlgorithm = "sha1" URLSignPara = "sign" )
const DefaultSignExpireTime = 86400
Variables ¶
var ( ErrForbidden = errors.New("bad athuntication") ErrNotFound = errors.New("not found") )
Functions ¶
func CreateSignature ¶
CreateSignature creates signature for string
func Encode ¶
Encode encodes the values into “URL encoded” form ("acl&bar=baz&foo=quux") sorted by key.
func GetNowNanoSec ¶
func GetNowNanoSec() int64
GetNowNanoSec returns t as a Unix time, the number of nanoseconds elapsed since January 1, 1970 UTC. The result is undefined if the Unix time in nanoseconds cannot be represented by an int64. Note that this means the result of calling UnixNano on the zero Time is undefined. 获取当前时间,从UTC开始的纳秒。
func GetNowSec ¶
func GetNowSec() int64
GetNowSec returns Unix time, the number of seconds elapsed since January 1, 1970 UTC. 获取当前时间,从UTC开始的秒数。
func GetURIPath ¶
func IsNotFoundError ¶
IsNotFoundError return true if the error is 404 error
func NewRequest ¶
Types ¶
type Bucket ¶
type Bucket struct { *Client // contains filtered or unexported fields }
func NewBucketFromURL ¶
func (*Bucket) DeleteObject ¶
func (*Bucket) DoGetObject ¶
func (b *Bucket) DoGetObject(key string, options ...Option) (*GetObjectResult, error)
func (*Bucket) ListObjects ¶
func (b *Bucket) ListObjects(options ...Option) (*ListObjectsResult, error)
type Error ¶
type GetObjectResult ¶
GetObjectResult is the result of DoGetObject
type ListObjectsResult ¶
type ListObjectsResult struct { XMLName xml.Name `xml:"ListBucketResult"` Name string `xml:"Name"` Prefix string `xml:"Prefix"` Marker string `xml:"Marker"` MaxKeys int `xml:"MaxKeys"` // IsTruncated is true if the results have been truncated because // there are more keys and prefixes than can fit in MaxKeys. // N.B. this is the opposite sense to that documented (incorrectly) in // http://goo.gl/YjQTc IsTruncated bool `xml:"IsTruncated"` Objects []ObjectProperties `xml:"Contents"` CommonPrefixes []string `xml:"CommonPrefixes>Prefix"` // if IsTruncated is true, pass NextMarker as marker argument to List() // to get the next set of keys NextMarker string `xml:"NextMarker"` }
The ListObjectsResult type holds the results of a List bucket operation.
type ObjectProperties ¶
type ObjectProperties struct { XMLName xml.Name `xml:"Contents"` Key string `xml:"Key"` // Object key LastModified time.Time `xml:"LastModified"` // Object last modified time Size int64 `xml:"Size"` // Object size // ETag gives the hex-encoded MD5 sum of the contents, // surrounded with double-quotes. ETag string `xml:"ETag"` // Object ETag Owner Owner `xml:"Owner"` // Object owner information StorageClass string `xml:"StorageClass"` // Object storage class (Standard, IA, Archive) }
The ObjectProperties type represents an item stored in an bucket.