aliyungo: github.com/denverdino/aliyungo/oss Index | Files

package oss

import "github.com/denverdino/aliyungo/oss"

Index

Package Files

authenticate_callback.go client.go export.go multi.go regions.go signature.go

Constants

const (
    Private           = ACL("private")
    PublicRead        = ACL("public-read")
    PublicReadWrite   = ACL("public-read-write")
    AuthenticatedRead = ACL("authenticated-read")
    BucketOwnerRead   = ACL("bucket-owner-read")
    BucketOwnerFull   = ACL("bucket-owner-full-control")
)
const (
    Hangzhou    = Region("oss-cn-hangzhou")
    Qingdao     = Region("oss-cn-qingdao")
    Beijing     = Region("oss-cn-beijing")
    Hongkong    = Region("oss-cn-hongkong")
    Shenzhen    = Region("oss-cn-shenzhen")
    Shanghai    = Region("oss-cn-shanghai")
    Zhangjiakou = Region("oss-cn-zhangjiakou")
    Huhehaote   = Region("oss-cn-huhehaote")

    USWest1      = Region("oss-us-west-1")
    USEast1      = Region("oss-us-east-1")
    APSouthEast1 = Region("oss-ap-southeast-1")
    APNorthEast1 = Region("oss-ap-northeast-1")
    APSouthEast2 = Region("oss-ap-southeast-2")

    MEEast1 = Region("oss-me-east-1")

    EUCentral1 = Region("oss-eu-central-1")
    EUWest1    = Region("oss-eu-west-1")

    DefaultRegion = Hangzhou
)

Constants of region definition

const DefaultContentType = "application/octet-stream"
const HeaderOSSPrefix = "x-oss-"

func AuthenticateCallBack Uses

func AuthenticateCallBack(pubKeyUrl, reqUrl, reqBody, authorization string) error

验证OSS向业务服务器发来的回调函数。 该方法是并发安全的 pubKeyUrl 回调请求头中[x-oss-pub-key-url]一项,以Base64编码 reqUrl oss所发来请求的url,由path+query组成 reqBody oss所发来请求的body authorization authorization为回调头中的签名

func SetAttemptStrategy Uses

func SetAttemptStrategy(s *util.AttemptStrategy)

func SetListMultiMax Uses

func SetListMultiMax(n int)

func SetListPartsMax Uses

func SetListPartsMax(n int)

type ACL Uses

type ACL string

type AccessControlPolicy Uses

type AccessControlPolicy struct {
    Owner  Owner
    Grants []string `xml:"AccessControlList>Grant"`
}

type Bucket Uses

type Bucket struct {
    *Client
    Name string
}

The Bucket type encapsulates operations with an bucket.

func (*Bucket) ACL Uses

func (b *Bucket) ACL() (result *AccessControlPolicy, err error)

ACL returns ACL of bucket

You can read doc at http://docs.aliyun.com/#/pub/oss/api-reference/bucket&GetBucketAcl

func (*Bucket) CopyLargeFile Uses

func (b *Bucket) CopyLargeFile(sourcePath string, destPath string, contentType string, perm ACL, options Options) error

func (*Bucket) CopyLargeFileInParallel Uses

func (b *Bucket) CopyLargeFileInParallel(sourcePath string, destPath string, contentType string, perm ACL, options Options, maxConcurrency int) error

Copy large file in the same bucket

func (*Bucket) Del Uses

func (b *Bucket) Del(path string) error

Del removes an object from the bucket.

You can read doc at http://docs.aliyun.com/#/pub/oss/api-reference/object&DeleteObject

func (*Bucket) DelBucket Uses

func (b *Bucket) DelBucket() (err error)

DelBucket removes an existing bucket. All objects in the bucket must be removed before the bucket itself can be removed.

You can read doc at http://docs.aliyun.com/#/pub/oss/api-reference/bucket&DeleteBucket

func (*Bucket) DelMulti Uses

func (b *Bucket) DelMulti(objects Delete) error

DelMulti removes up to 1000 objects from the bucket.

You can read doc at http://docs.aliyun.com/#/pub/oss/api-reference/object&DeleteMultipleObjects

func (*Bucket) Exists Uses

func (b *Bucket) Exists(path string) (exists bool, err error)

Exists checks whether or not an object exists on an bucket using a HEAD request.

func (*Bucket) Get Uses

func (b *Bucket) Get(path string) (data []byte, err error)

Get retrieves an object from an bucket.

You can read doc at http://docs.aliyun.com/#/pub/oss/api-reference/object&GetObject

func (*Bucket) GetContentLength Uses

func (b *Bucket) GetContentLength(sourcePath string) (int64, error)

func (*Bucket) GetReader Uses

func (b *Bucket) GetReader(path string) (rc io.ReadCloser, err error)

GetReader retrieves an object from an bucket, returning the body of the HTTP response. It is the caller's responsibility to call Close on rc when finished reading.

func (*Bucket) GetResponse Uses

func (b *Bucket) GetResponse(path string) (resp *http.Response, err error)

GetResponse retrieves an object from an bucket, returning the HTTP response. It is the caller's responsibility to call Close on rc when finished reading

func (*Bucket) GetResponseWithHeaders Uses

func (b *Bucket) GetResponseWithHeaders(path string, headers http.Header) (resp *http.Response, err error)

GetResponseWithHeaders retrieves an object from an bucket Accepts custom headers to be sent as the second parameter returning the body of the HTTP response. It is the caller's responsibility to call Close on rc when finished reading

func (*Bucket) GetResponseWithParamsAndHeaders Uses

func (b *Bucket) GetResponseWithParamsAndHeaders(path string, params url.Values, headers http.Header) (resp *http.Response, err error)

func (*Bucket) GetWithParams Uses

func (b *Bucket) GetWithParams(path string, params url.Values) (data []byte, err error)

Get retrieves an object from an bucket.

func (*Bucket) Head Uses

func (b *Bucket) Head(path string, headers http.Header) (*http.Response, error)

Head HEADs an object in the bucket, returns the response with

You can read doc at http://docs.aliyun.com/#/pub/oss/api-reference/object&HeadObject

func (*Bucket) Info Uses

func (b *Bucket) Info() (BucketInfo, error)

Info query basic information about the bucket

You can read doc at https://help.aliyun.com/document_detail/31968.html

func (*Bucket) InitMulti Uses

func (b *Bucket) InitMulti(key string, contType string, perm ACL, options Options) (*Multi, error)

InitMulti initializes a new multipart upload at the provided key inside b and returns a value for manipulating it.

You can read doc at http://docs.aliyun.com/#/pub/oss/api-reference/multipart-upload&InitiateMultipartUpload

func (*Bucket) List Uses

func (b *Bucket) List(prefix, delim, marker string, max int) (result *ListResp, err error)

List returns information about objects in an bucket.

The prefix parameter limits the response to keys that begin with the specified prefix.

The delim parameter causes the response to group all of the keys that share a common prefix up to the next delimiter in a single entry within the CommonPrefixes field. You can use delimiters to separate a bucket into different groupings of keys, similar to how folders would work.

The marker parameter specifies the key to start with when listing objects in a bucket. OSS lists objects in alphabetical order and will return keys alphabetically greater than the marker.

The max parameter specifies how many keys + common prefixes to return in the response, at most 1000. The default is 100.

For example, given these keys in a bucket:

index.html
index2.html
photos/2006/January/sample.jpg
photos/2006/February/sample2.jpg
photos/2006/February/sample3.jpg
photos/2006/February/sample4.jpg

Listing this bucket with delimiter set to "/" would yield the following result:

&ListResp{
    Name:      "sample-bucket",
    MaxKeys:   1000,
    Delimiter: "/",
    Contents:  []Key{
        {Key: "index.html", "index2.html"},
    },
    CommonPrefixes: []string{
        "photos/",
    },
}

Listing the same bucket with delimiter set to "/" and prefix set to "photos/2006/" would yield the following result:

&ListResp{
    Name:      "sample-bucket",
    MaxKeys:   1000,
    Delimiter: "/",
    Prefix:    "photos/2006/",
    CommonPrefixes: []string{
        "photos/2006/February/",
        "photos/2006/January/",
    },
}

You can read doc at http://docs.aliyun.com/#/pub/oss/api-reference/bucket&GetBucket

func (*Bucket) ListMulti Uses

func (b *Bucket) ListMulti(prefix, delim string) (multis []*Multi, prefixes []string, err error)

ListMulti returns the list of unfinished multipart uploads in b.

The prefix parameter limits the response to keys that begin with the specified prefix. You can use prefixes to separate a bucket into different groupings of keys (to get the feeling of folders, for example).

The delim parameter causes the response to group all of the keys that share a common prefix up to the next delimiter in a single entry within the CommonPrefixes field. You can use delimiters to separate a bucket into different groupings of keys, similar to how folders would work.

func (*Bucket) Location Uses

func (b *Bucket) Location() (string, error)

func (*Bucket) Multi Uses

func (b *Bucket) Multi(key, contType string, perm ACL, options Options) (*Multi, error)

Multi returns a multipart upload handler for the provided key inside b. If a multipart upload exists for key, it is returned, otherwise a new multipart upload is initiated with contType and perm.

func (*Bucket) Path Uses

func (b *Bucket) Path(path string) string

func (*Bucket) PostFormArgs Uses

func (b *Bucket) PostFormArgs(path string, expires time.Time, redirect string) (action string, fields map[string]string)

PostFormArgs returns the action and input fields needed to allow anonymous uploads to a bucket within the expiration limit

func (*Bucket) PostFormArgsEx Uses

func (b *Bucket) PostFormArgsEx(path string, expires time.Time, redirect string, conds []string) (action string, fields map[string]string)

PostFormArgsEx returns the action and input fields needed to allow anonymous uploads to a bucket within the expiration limit Additional conditions can be specified with conds

func (*Bucket) Put Uses

func (b *Bucket) Put(path string, data []byte, contType string, perm ACL, options Options) error

Put inserts an object into the bucket.

You can read doc at http://docs.aliyun.com/#/pub/oss/api-reference/object&PutObject

func (*Bucket) PutBucket Uses

func (b *Bucket) PutBucket(perm ACL) error

PutBucket creates a new bucket.

You can read doc at http://docs.aliyun.com/#/pub/oss/api-reference/bucket&PutBucket

func (*Bucket) PutBucketSubresource Uses

func (b *Bucket) PutBucketSubresource(subresource string, r io.Reader, length int64) error

func (*Bucket) PutBucketWebsite Uses

func (b *Bucket) PutBucketWebsite(configuration WebsiteConfiguration) error

PutBucketWebsite configures a bucket as a website.

You can read doc at http://docs.aliyun.com/#/pub/oss/api-reference/bucket&PutBucketWebsite

func (*Bucket) PutCopy Uses

func (b *Bucket) PutCopy(path string, perm ACL, options CopyOptions, source string) (*CopyObjectResult, error)

PutCopy puts a copy of an object given by the key path into bucket b using b.Path as the target key

You can read doc at http://docs.aliyun.com/#/pub/oss/api-reference/object&CopyObject

func (*Bucket) PutFile Uses

func (b *Bucket) PutFile(path string, file *os.File, perm ACL, options Options) error

PutFile creates/updates object with file

func (*Bucket) PutReader Uses

func (b *Bucket) PutReader(path string, r io.Reader, length int64, contType string, perm ACL, options Options) error

PutReader inserts an object into the bucket by consuming data from r until EOF.

func (*Bucket) SignedURL Uses

func (b *Bucket) SignedURL(path string, expires time.Time) string

SignedURL returns a signed URL that allows anyone holding the URL to retrieve the object at path. The signature is valid until expires.

func (*Bucket) SignedURLWithArgs Uses

func (b *Bucket) SignedURLWithArgs(path string, expires time.Time, params url.Values, headers http.Header) string

SignedURLWithArgs returns a signed URL that allows anyone holding the URL to retrieve the object at path. The signature is valid until expires.

func (*Bucket) SignedURLWithMethod Uses

func (b *Bucket) SignedURLWithMethod(method, path string, expires time.Time, params url.Values, headers http.Header) string

SignedURLWithMethod returns a signed URL that allows anyone holding the URL to either retrieve the object at path or make a HEAD request against it. The signature is valid until expires.

func (*Bucket) SignedURLWithMethodForAssumeRole Uses

func (b *Bucket) SignedURLWithMethodForAssumeRole(method, path string, expires time.Time, params url.Values, headers http.Header) string

func (*Bucket) URL Uses

func (b *Bucket) URL(path string) string

URL returns a non-signed URL that allows retriving the object at path. It only works if the object is publicly readable (see SignedURL).

func (*Bucket) UploadSignedURL Uses

func (b *Bucket) UploadSignedURL(name, method, contentType string, expires time.Time) string

UploadSignedURL returns a signed URL that allows anyone holding the URL to upload the object at path. The signature is valid until expires. contenttype is a string like image/png name is the resource name in OSS terminology like images/ali.png [obviously excluding the bucket name itself]

type BucketInfo Uses

type BucketInfo struct {
    Name             string
    CreationDate     string
    ExtranetEndpoint string
    IntranetEndpoint string
    Location         string
    Grant            string `xml:"AccessControlList>Grant"`
}

type Client Uses

type Client struct {
    AccessKeyId     string
    AccessKeySecret string
    SecurityToken   string
    Region          Region
    Internal        bool
    Secure          bool
    ConnectTimeout  time.Duration
    Transport       http.RoundTripper
    // contains filtered or unexported fields
}

The Client type encapsulates operations with an OSS region.

func NewOSSClient Uses

func NewOSSClient(region Region, internal bool, accessKeyId string, accessKeySecret string, secure bool) *Client

func NewOSSClientForAssumeRole Uses

func NewOSSClientForAssumeRole(region Region, internal bool, accessKeyId string, accessKeySecret string, securityToken string, secure bool) *Client

func (*Client) Bucket Uses

func (client *Client) Bucket(name string) *Bucket

Bucket returns a Bucket with the given name.

func (*Client) GetService Uses

func (client *Client) GetService() (*GetServiceResp, error)

GetService gets a list of all buckets owned by an account.

func (*Client) SetDebug Uses

func (client *Client) SetDebug(debug bool)

SetDebug sets debug mode to log the request/response message

func (*Client) SetEndpoint Uses

func (client *Client) SetEndpoint(endpoint string)

override default endpoint

type CopyObjectResult Uses

type CopyObjectResult struct {
    ETag         string
    LastModified string
}

CopyObjectResult is the output from a Copy request

type CopyOptions Uses

type CopyOptions struct {
    Headers           http.Header
    CopySourceOptions string
    MetadataDirective string

    ServerSideEncryption      bool
    ServerSideEncryptionKeyID string
}

type Delete Uses

type Delete struct {
    Quiet   bool     `xml:"Quiet,omitempty"`
    Objects []Object `xml:"Object"`
}

type Error Uses

type Error struct {
    StatusCode int    // HTTP status code (200, 403, ...)
    Code       string // OSS error code ("UnsupportedOperation", ...)
    Message    string // The human-oriented error message
    BucketName string
    RequestId  string
    HostId     string
}

Error represents an error in an operation with OSS.

func (*Error) Error Uses

func (e *Error) Error() string

type ErrorDocument Uses

type ErrorDocument struct {
    Key string `xml:"Key"`
}

type GetBucketInfoResp Uses

type GetBucketInfoResp struct {
    Bucket BucketInfo
}

type GetLocationResp Uses

type GetLocationResp struct {
    Location string `xml:",innerxml"`
}

type GetServiceResp Uses

type GetServiceResp struct {
    Owner   Owner
    Buckets []BucketInfo `xml:">Bucket"`
}

type IndexDocument Uses

type IndexDocument struct {
    Suffix string `xml:"Suffix"`
}

type Key Uses

type Key struct {
    Key          string
    LastModified string
    Type         string
    Size         int64
    // ETag gives the hex-encoded MD5 sum of the contents,
    // surrounded with double-quotes.
    ETag         string
    StorageClass string
    Owner        Owner
}

The Key type represents an item stored in an bucket.

type ListResp Uses

type ListResp struct {
    Name      string
    Prefix    string
    Delimiter string
    Marker    string
    MaxKeys   int
    // 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
    Contents       []Key
    CommonPrefixes []string `xml:">Prefix"`
    // if IsTruncated is true, pass NextMarker as marker argument to List()
    // to get the next set of keys
    NextMarker string
}

The ListResp type holds the results of a List bucket operation.

type Multi Uses

type Multi struct {
    Bucket   *Bucket
    Key      string
    UploadId string
}

func (*Multi) Abort Uses

func (m *Multi) Abort() error

Abort deletes an unifinished multipart upload and any previously uploaded parts for it.

After a multipart upload is aborted, no additional parts can be uploaded using it. However, if any part uploads are currently in progress, those part uploads might or might not succeed. As a result, it might be necessary to abort a given multipart upload multiple times in order to completely free all storage consumed by all parts.

NOTE: If the described scenario happens to you, please report back to the goamz authors with details. In the future such retrying should be handled internally, but it's not clear what happens precisely (Is an error returned? Is the issue completely undetectable?).

You can read doc at http://docs.aliyun.com/#/pub/oss/api-reference/multipart-upload&AbortMultipartUpload

func (*Multi) Complete Uses

func (m *Multi) Complete(parts []Part) error

Complete assembles the given previously uploaded parts into the final object. This operation may take several minutes.

func (*Multi) ListParts Uses

func (m *Multi) ListParts() ([]Part, error)

ListParts for backcompatability. See the documentation for ListPartsFull

func (*Multi) ListPartsFull Uses

func (m *Multi) ListPartsFull(partNumberMarker int, maxParts int) ([]Part, error)

ListPartsFull returns the list of previously uploaded parts in m, ordered by part number (Only parts with higher part numbers than partNumberMarker will be listed). Only up to maxParts parts will be returned.

func (*Multi) PutAll Uses

func (m *Multi) PutAll(r ReaderAtSeeker, partSize int64) ([]Part, error)

PutAll sends all of r via a multipart upload with parts no larger than partSize bytes, which must be set to at least 5MB. Parts previously uploaded are either reused if their checksum and size match the new part, or otherwise overwritten with the new content. PutAll returns all the parts of m (reused or not).

func (*Multi) PutPart Uses

func (m *Multi) PutPart(n int, r io.ReadSeeker) (Part, error)

PutPart sends part n of the multipart upload, reading all the content from r. Each part, except for the last one, must be at least 5MB in size.

You can read doc at http://docs.aliyun.com/#/pub/oss/api-reference/multipart-upload&UploadPart

func (*Multi) PutPartCopy Uses

func (m *Multi) PutPartCopy(n int, options CopyOptions, source string) (*CopyObjectResult, Part, error)

func (*Multi) PutPartCopyWithContentLength Uses

func (m *Multi) PutPartCopyWithContentLength(n int, options CopyOptions, source string, contentLength int64) (*CopyObjectResult, Part, error)

You can read doc at http://docs.aliyun.com/#/pub/oss/api-reference/multipart-upload&UploadPartCopy

func (*Multi) PutPartWithTimeout Uses

func (m *Multi) PutPartWithTimeout(n int, r io.ReadSeeker, timeout time.Duration) (Part, error)

type Object Uses

type Object struct {
    Key       string `xml:"Key"`
    VersionId string `xml:"VersionId,omitempty"`
}

type Options Uses

type Options struct {
    ServerSideEncryption      bool
    ServerSideEncryptionKeyID string

    Meta               map[string][]string
    ContentEncoding    string
    CacheControl       string
    ContentMD5         string
    ContentDisposition string
}

Options struct

type Owner Uses

type Owner struct {
    ID          string
    DisplayName string
}

The Owner type represents the owner of the object in an bucket.

type Part Uses

type Part struct {
    N    int `xml:"PartNumber"`
    ETag string
    Size int64
}

type ReaderAtSeeker Uses

type ReaderAtSeeker interface {
    io.ReaderAt
    io.ReadSeeker
}

type RedirectAllRequestsTo Uses

type RedirectAllRequestsTo struct {
    HostName string `xml:"HostName"`
    Protocol string `xml:"Protocol,omitempty"`
}

type Region Uses

type Region string

Region represents OSS region

func (Region) GetEndpoint Uses

func (r Region) GetEndpoint(internal bool, bucket string, secure bool) string

GetEndpoint returns endpoint of region

func (Region) GetInternalEndpoint Uses

func (r Region) GetInternalEndpoint(bucket string, secure bool) string

GetInternalEndpoint returns internal endpoint of region

func (Region) GetInternetEndpoint Uses

func (r Region) GetInternetEndpoint(bucket string, secure bool) string

GetInternetEndpoint returns internet endpoint of region

func (Region) GetVPCInternalEndpoint Uses

func (r Region) GetVPCInternalEndpoint(bucket string, secure bool) string

GetInternalEndpoint returns internal endpoint of region

type RoutingRule Uses

type RoutingRule struct {
    ConditionKeyPrefixEquals     string `xml:"Condition>KeyPrefixEquals"`
    RedirectReplaceKeyPrefixWith string `xml:"Redirect>ReplaceKeyPrefixWith,omitempty"`
    RedirectReplaceKeyWith       string `xml:"Redirect>ReplaceKeyWith,omitempty"`
}

type TimeoutError Uses

type TimeoutError interface {
    error
    Timeout() bool // Is the error a timeout?
}

type WebsiteConfiguration Uses

type WebsiteConfiguration struct {
    XMLName               xml.Name               `xml:"http://doc.oss-cn-hangzhou.aliyuncs.com WebsiteConfiguration"`
    IndexDocument         *IndexDocument         `xml:"IndexDocument,omitempty"`
    ErrorDocument         *ErrorDocument         `xml:"ErrorDocument,omitempty"`
    RoutingRules          *[]RoutingRule         `xml:"RoutingRules>RoutingRule,omitempty"`
    RedirectAllRequestsTo *RedirectAllRequestsTo `xml:"RedirectAllRequestsTo,omitempty"`
}

Package oss imports 31 packages (graph) and is imported by 9 packages. Updated 2020-11-15. Refresh now. Tools for package owners.