aliyun-oss-go-sdk: github.com/aliyun/aliyun-oss-go-sdk/oss Index | Files

package oss

import "github.com/aliyun/aliyun-oss-go-sdk/oss"

Package oss implements functions for access oss service. It has two main struct Client and Bucket.

Index

Package Files

auth.go bucket.go client.go conf.go conn.go const.go crc.go download.go error.go mime.go model.go multicopy.go multipart.go option.go progress.go transport_1_7.go type.go upload.go utils.go

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 (
    HTTPParamExpires       = "Expires"
    HTTPParamAccessKeyID   = "OSSAccessKeyId"
    HTTPParamSignature     = "Signature"
    HTTPParamSecurityToken = "security-token"
)

HTTP Param

const (
    MaxPartSize = 5 * 1024 * 1024 * 1024 // Max part size, 5GB
    MinPartSize = 100 * 1024             // Min part size, 100KB

    FilePermMode = os.FileMode(0664) // Default file permission

    TempFilePrefix = "oss-go-temp-" // Temp file prefix
    TempFileSuffix = ".temp"        // Temp file suffix

    CheckpointFileSuffix = ".cp" // Checkpoint file suffix

    Version = "1.9.0" // Go SDK version
)

Other constants

func CRC64Combine Uses

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

CRC64Combine combines CRC64

func GetNowGMT Uses

func GetNowGMT() string

GetNowGMT gets the current time in GMT format.

func GetNowNanoSec Uses

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. gets the current time in Unix time, in nanoseconds.

func GetNowSec Uses

func GetNowSec() int64

GetNowSec returns Unix time, the number of seconds elapsed since January 1, 1970 UTC. gets the current time in Unix time, in seconds.

func GetPartEnd Uses

func GetPartEnd(begin int64, total int64, per int64) int64

GetPartEnd calculates the end position

func NewCRC Uses

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

NewCRC creates a new hash.Hash64 computing the CRC64 checksum using the polynomial represented by the Table.

func TeeReader Uses

func TeeReader(reader io.Reader, writer io.Writer, totalBytes int64, listener ProgressListener, tracker *readerTracker) io.Reader

TeeReader returns a Reader that writes to w what it reads from r. All reads from r performed through it are matched with corresponding writes to w. There is no internal buffering - the write must complete before the read completes. Any error encountered while writing is reported as a read error.

func TypeByExtension Uses

func TypeByExtension(filePath string) string

TypeByExtension returns the MIME type associated with the file extension ext. gets the file's MIME type for HTTP header Content-Type

type ACLType Uses

type ACLType string

ACLType bucket/object ACL

const (
    // ACLPrivate definition : private read and write
    ACLPrivate ACLType = "private"

    // ACLPublicRead definition : public read and private write
    ACLPublicRead ACLType = "public-read"

    // ACLPublicReadWrite definition : public read and public write
    ACLPublicReadWrite ACLType = "public-read-write"

    // ACLDefault Object. It's only applicable for object.
    ACLDefault ACLType = "default"
)

type AppendObjectRequest Uses

type AppendObjectRequest struct {
    ObjectKey string
    Reader    io.Reader
    Position  int64
}

AppendObjectRequest is the requtest of DoAppendObject

type AppendObjectResult Uses

type AppendObjectResult struct {
    NextPosition int64
    CRC          uint64
}

AppendObjectResult is the result of DoAppendObject

type Bucket Uses

type Bucket struct {
    Client     Client
    BucketName string
}

Bucket implements the operations of object.

func (Bucket) AbortMultipartUpload Uses

func (bucket Bucket) AbortMultipartUpload(imur InitiateMultipartUploadResult) error

AbortMultipartUpload aborts the multipart upload.

imur the return value of InitiateMultipartUpload.

error it's nil if the operation succeeds, otherwise it's an error object.

func (Bucket) AppendObject Uses

func (bucket Bucket) AppendObject(objectKey string, reader io.Reader, appendPosition int64, options ...Option) (int64, error)

AppendObject uploads the data in the way of appending an existing or new object.

AppendObject the parameter appendPosition specifies which postion (in the target object) to append. For the first append (to a non-existing file), the appendPosition should be 0. The appendPosition in the subsequent calls will be the current object length. For example, the first appendObject's appendPosition is 0 and it uploaded 65536 bytes data, then the second call's position is 65536. The response header x-oss-next-append-position after each successful request also specifies the next call's append position (so the caller need not to maintain this information).

objectKey the target object to append to. reader io.Reader. The read instance for reading the data to append. appendPosition the start position to append. destObjectProperties the options for the first appending, such as CacheControl, ContentDisposition, ContentEncoding,

Expires, ServerSideEncryption, ObjectACL.

int64 the next append position, it's valid when error is nil. error it's nil if no error, otherwise it's an error object.

func (Bucket) CompleteMultipartUpload Uses

func (bucket Bucket) CompleteMultipartUpload(imur InitiateMultipartUploadResult,
    parts []UploadPart) (CompleteMultipartUploadResult, error)

CompleteMultipartUpload completes the multipart upload.

imur the return value of InitiateMultipartUpload. parts the array of return value of UploadPart/UploadPartFromFile/UploadPartCopy.

CompleteMultipartUploadResponse the return value when the call succeeds. Only valid when the error is nil. error it's nil if the operation succeeds, otherwise it's an error object.

func (Bucket) CopyFile Uses

func (bucket Bucket) CopyFile(srcBucketName, srcObjectKey, destObjectKey string, partSize int64, options ...Option) error

CopyFile is multipart copy object

srcBucketName source bucket name srcObjectKey source object name destObjectKey target object name in the form of bucketname.objectkey partSize the part size in byte. options object's contraints. Check out function InitiateMultipartUpload.

error it's nil if the operation succeeds, otherwise it's an error object.

func (Bucket) CopyObject Uses

func (bucket Bucket) CopyObject(srcObjectKey, destObjectKey string, options ...Option) (CopyObjectResult, error)

CopyObject copies the object inside the bucket.

srcObjectKey the source object to copy. destObjectKey the target object to copy. options options for copying an object. You can specify the conditions of copy. The valid conditions are CopySourceIfMatch,

CopySourceIfNoneMatch, CopySourceIfModifiedSince, CopySourceIfUnmodifiedSince, MetadataDirective.
Also you can specify the target object's attributes, such as CacheControl, ContentDisposition, ContentEncoding, Expires,
ServerSideEncryption, ObjectACL, Meta. Refer to the link below for more details :
https://help.aliyun.com/document_detail/oss/api-reference/object/CopyObject.html

error it's nil if no error, otherwise it's an error object.

func (Bucket) CopyObjectFrom Uses

func (bucket Bucket) CopyObjectFrom(srcBucketName, srcObjectKey, destObjectKey string, options ...Option) (CopyObjectResult, error)

CopyObjectFrom copies the object to another bucket.

srcBucketName source bucket name. srcObjectKey source object name. destObjectKey target object name. The target bucket name is Bucket.BucketName. options copy options. Check out parameter options in function CopyObject.

error it's nil if no error, otherwise it's an error object.

func (Bucket) CopyObjectTo Uses

func (bucket Bucket) CopyObjectTo(destBucketName, destObjectKey, srcObjectKey string, options ...Option) (CopyObjectResult, error)

CopyObjectTo copies the object to another bucket.

srcObjectKey source object key. The source bucket is Bucket.BucketName . destBucketName target bucket name. destObjectKey target object name. options copy options, check out parameter options in function CopyObject for more details.

error it's nil if no error, otherwise it's an error object.

func (Bucket) DeleteObject Uses

func (bucket Bucket) DeleteObject(objectKey string) error

DeleteObject deletes the object.

objectKey the object key to delete.

error it's nil if no error, otherwise it's an error object.

func (Bucket) DeleteObjects Uses

func (bucket Bucket) DeleteObjects(objectKeys []string, options ...Option) (DeleteObjectsResult, error)

DeleteObjects deletes multiple objects.

objectKeys the object keys to delete. options the options for deleting objects.

Supported option is DeleteObjectsQuiet which means it will not return error even deletion failed (not recommended). By default it's not used.

DeleteObjectsResult the result object. error it's nil if no error, otherwise it's an error object.

func (Bucket) DoAppendObject Uses

func (bucket Bucket) DoAppendObject(request *AppendObjectRequest, options []Option) (*AppendObjectResult, error)

DoAppendObject is the actual API that does the object append.

request the request object for appending object. options the options for appending object.

AppendObjectResult the result object for appending object. error it's nil if no error, otherwise it's an error object.

func (Bucket) DoGetObject Uses

func (bucket Bucket) DoGetObject(request *GetObjectRequest, options []Option) (*GetObjectResult, error)

DoGetObject is the actual API that gets the object. It's the internal function called by other public APIs.

request the request to download the object. options the options for downloading the file. Checks out the parameter options in method GetObject.

GetObjectResult the result instance of getting the object. error it's nil if no error, otherwise it's an error object.

func (Bucket) DoGetObjectWithURL Uses

func (bucket Bucket) DoGetObjectWithURL(signedURL string, options []Option) (*GetObjectResult, error)

DoGetObjectWithURL is the actual API that downloads the file with the signed URL.

signedURL the signed URL. options the options for getting object. Check out parameter options in GetObject for the reference.

GetObjectResult the result object when the error is nil. error it's nil if no error, otherwise it's an error object.

func (Bucket) DoPutObject Uses

func (bucket Bucket) DoPutObject(request *PutObjectRequest, options []Option) (*Response, error)

DoPutObject does the actual upload work.

request the request instance for uploading an object. options the options for uploading an object.

Response the response from OSS. error it's nil if no error, otherwise it's an error object.

func (Bucket) DoPutObjectWithURL Uses

func (bucket Bucket) DoPutObjectWithURL(signedURL string, reader io.Reader, options []Option) (*Response, error)

DoPutObjectWithURL is the actual API that does the upload with URL work(internal for SDK)

signedURL the signed URL. reader io.Reader the read instance for getting the data to upload. options options for uploading.

Response the response object which contains the HTTP response. error it's nil if no error, otherwise it's an error object.

func (Bucket) DoUploadPart Uses

func (bucket Bucket) DoUploadPart(request *UploadPartRequest, options []Option) (*UploadPartResult, error)

DoUploadPart does the actual part upload.

request part upload request

UploadPartResult the result of uploading part. error it's nil if the operation succeeds, otherwise it's an error object.

func (Bucket) DownloadFile Uses

func (bucket Bucket) DownloadFile(objectKey, filePath string, partSize int64, options ...Option) error

DownloadFile downloads files with multipart download.

objectKey the object key. filePath the local file to download from objectKey in OSS. partSize the part size in bytes. options object's constraints, check out GetObject for the reference.

error it's nil when the call succeeds, otherwise it's an error object.

func (Bucket) GetObject Uses

func (bucket Bucket) GetObject(objectKey string, options ...Option) (io.ReadCloser, error)

GetObject downloads the object.

objectKey the object key. options the options for downloading the object. The valid values are: Range, IfModifiedSince, IfUnmodifiedSince, IfMatch,

IfNoneMatch, AcceptEncoding. For more details, please check out:
https://help.aliyun.com/document_detail/oss/api-reference/object/GetObject.html

io.ReadCloser reader instance for reading data from response. It must be called close() after the usage and only valid when error is nil. error it's nil if no error, otherwise it's an error object.

func (Bucket) GetObjectACL Uses

func (bucket Bucket) GetObjectACL(objectKey string) (GetObjectACLResult, error)

GetObjectACL gets object's ACL

objectKey the object to get ACL from.

GetObjectACLResult the result object when error is nil. GetObjectACLResult.Acl is the object ACL. error it's nil if no error, otherwise it's an error object.

func (Bucket) GetObjectDetailedMeta Uses

func (bucket Bucket) GetObjectDetailedMeta(objectKey string, options ...Option) (http.Header, error)

GetObjectDetailedMeta gets the object's detailed metadata

objectKey object key. options the constraints of the object. Only when the object meets the requirements this method will return the metadata. Otherwise returns error. Valid options are IfModifiedSince, IfUnmodifiedSince,

IfMatch, IfNoneMatch. For more details check out https://help.aliyun.com/document_detail/oss/api-reference/object/HeadObject.html

http.Header object meta when error is nil. error it's nil if no error, otherwise it's an error object.

func (Bucket) GetObjectMeta Uses

func (bucket Bucket) GetObjectMeta(objectKey string) (http.Header, error)

GetObjectMeta gets object metadata.

GetObjectMeta is more lightweight than GetObjectDetailedMeta as it only returns basic metadata including ETag size, LastModified. The size information is in the HTTP header Content-Length.

objectKey object key

http.Header the object's metadata, valid when error is nil. error it's nil if no error, otherwise it's an error object.

func (Bucket) GetObjectToFile Uses

func (bucket Bucket) GetObjectToFile(objectKey, filePath string, options ...Option) error

GetObjectToFile downloads the data to a local file.

objectKey the object key to download. filePath the local file to store the object data. options the options for downloading the object. Refer to the parameter options in method GetObject for more details.

error it's nil if no error, otherwise it's an error object.

func (Bucket) GetObjectToFileWithURL Uses

func (bucket Bucket) GetObjectToFileWithURL(signedURL, filePath string, options ...Option) error

GetObjectToFileWithURL downloads the object into a local file with the signed URL.

signedURL the signed URL filePath the local file path to download to. options the options for downloading object. Check out the parameter options in function GetObject for the reference.

error it's nil if no error, otherwise it's an error object.

func (Bucket) GetObjectWithURL Uses

func (bucket Bucket) GetObjectWithURL(signedURL string, options ...Option) (io.ReadCloser, error)

GetObjectWithURL downloads the object and returns the reader instance, with the signed URL.

signedURL the signed URL. options options for downloading the object. Valid options are IfModifiedSince, IfUnmodifiedSince, IfMatch,

IfNoneMatch, AcceptEncoding. For more information, check out the following link:
https://help.aliyun.com/document_detail/oss/api-reference/object/GetObject.html

io.ReadCloser the reader object for getting the data from response. It needs be closed after the usage. It's only valid when error is nil. error it's nil if no error, otherwise it's an error object.

func (bucket Bucket) GetSymlink(objectKey string) (http.Header, error)

GetSymlink gets the symlink object with the specified key. If the symlink object does not exist, returns 404.

objectKey the symlink object's key.

error it's nil if no error, otherwise it's an error object.

When error is nil, the target file key is in the X-Oss-Symlink-Target header of the returned object.

func (Bucket) InitiateMultipartUpload Uses

func (bucket Bucket) InitiateMultipartUpload(objectKey string, options ...Option) (InitiateMultipartUploadResult, error)

InitiateMultipartUpload initializes multipart upload

objectKey object name options the object constricts for upload. The valid options are CacheControl, ContentDisposition, ContentEncoding, Expires,

ServerSideEncryption, Meta, check out the following link:
https://help.aliyun.com/document_detail/oss/api-reference/multipart-upload/InitiateMultipartUpload.html

InitiateMultipartUploadResult the return value of the InitiateMultipartUpload, which is used for calls later on such as UploadPartFromFile,UploadPartCopy. error it's nil if the operation succeeds, otherwise it's an error object.

func (Bucket) IsObjectExist Uses

func (bucket Bucket) IsObjectExist(objectKey string) (bool, error)

IsObjectExist checks if the object exists.

bool flag of object's existence (true:exists; false:non-exist) when error is nil.

error it's nil if no error, otherwise it's an error object.

func (Bucket) ListMultipartUploads Uses

func (bucket Bucket) ListMultipartUploads(options ...Option) (ListMultipartUploadResult, error)

ListMultipartUploads lists all ongoing multipart upload tasks

options listObject's filter. Prefix specifies the returned object's prefix; KeyMarker specifies the returned object's start point in lexicographic order;

MaxKeys specifies the max entries to return; Delimiter is the character for grouping object keys.

ListMultipartUploadResponse the return value if it succeeds, only valid when error is nil. error it's nil if the operation succeeds, otherwise it's an error object.

func (Bucket) ListObjects Uses

func (bucket Bucket) ListObjects(options ...Option) (ListObjectsResult, error)

ListObjects lists the objects under the current bucket.

options it contains all the filters for listing objects.

It could specify a prefix filter on object keys,  the max keys count to return and the object key marker and the delimiter for grouping object names.
The key marker means the returned objects' key must be greater than it in lexicographic order.

For example, if the bucket has 8 objects, my-object-1, my-object-11, my-object-2, my-object-21,
my-object-22, my-object-3, my-object-31, my-object-32. If the prefix is my-object-2 (no other filters), then it returns
my-object-2, my-object-21, my-object-22 three objects. If the marker is my-object-22 (no other filters), then it returns
my-object-3, my-object-31, my-object-32 three objects. If the max keys is 5, then it returns 5 objects.
The three filters could be used together to achieve filter and paging functionality.
If the prefix is the folder name, then it could list all files under this folder (including the files under its subfolders).
But if the delimiter is specified with '/', then it only returns that folder's files (no subfolder's files). The direct subfolders are in the commonPrefixes properties.
For example, if the bucket has three objects fun/test.jpg, fun/movie/001.avi, fun/movie/007.avi. And if the prefix is "fun/", then it returns all three objects.
But if the delimiter is '/', then only "fun/test.jpg" is returned as files and fun/movie/ is returned as common prefix.

For common usage scenario, check out sample/list_object.go.

ListObjectsResponse the return value after operation succeeds (only valid when error is nil).

func (Bucket) ListUploadedParts Uses

func (bucket Bucket) ListUploadedParts(imur InitiateMultipartUploadResult) (ListUploadedPartsResult, error)

ListUploadedParts lists the uploaded parts.

imur the return value of InitiateMultipartUpload.

ListUploadedPartsResponse the return value if it succeeds, only valid when error is nil. error it's nil if the operation succeeds, otherwise it's an error object.

func (Bucket) PutObject Uses

func (bucket Bucket) PutObject(objectKey string, reader io.Reader, options ...Option) error

PutObject creates a new object and it will overwrite the original one if it exists already.

objectKey the object key in UTF-8 encoding. The length must be between 1 and 1023, and cannot start with "/" or "\". reader io.Reader instance for reading the data for uploading options the options for uploading the object. The valid options here are CacheControl, ContentDisposition, ContentEncoding

Expires, ServerSideEncryption, ObjectACL and Meta. Refer to the link below for more details.
https://help.aliyun.com/document_detail/oss/api-reference/object/PutObject.html

error it's nil if no error, otherwise it's an error object.

func (Bucket) PutObjectFromFile Uses

func (bucket Bucket) PutObjectFromFile(objectKey, filePath string, options ...Option) error

PutObjectFromFile creates a new object from the local file.

objectKey object key. filePath the local file path to upload. options the options for uploading the object. Refer to the parameter options in PutObject for more details.

error it's nil if no error, otherwise it's an error object.

func (Bucket) PutObjectFromFileWithURL Uses

func (bucket Bucket) PutObjectFromFileWithURL(signedURL, filePath string, options ...Option) error

PutObjectFromFileWithURL uploads an object from a local file with the signed URL. PutObjectFromFileWithURL It does not generate mimetype according to object key's name or the local file name.

signedURL the signed URL. filePath local file path, such as dirfile.txt, for uploading. options options for uploading, same as the options in PutObject function.

error it's nil if no error, otherwise it's an error object.

func (Bucket) PutObjectWithURL Uses

func (bucket Bucket) PutObjectWithURL(signedURL string, reader io.Reader, options ...Option) error

PutObjectWithURL uploads an object with the URL. If the object exists, it will be overwritten. PutObjectWithURL It will not generate minetype according to the key name.

signedURL signed URL. reader io.Reader the read instance for reading the data for the upload. options the options for uploading the data. The valid options are CacheControl, ContentDisposition, ContentEncoding,

Expires, ServerSideEncryption, ObjectACL and custom metadata. Check out the following link for details:
https://help.aliyun.com/document_detail/oss/api-reference/object/PutObject.html

error it's nil if no error, otherwise it's an error object.

func (bucket Bucket) PutSymlink(symObjectKey string, targetObjectKey string, options ...Option) error

PutSymlink creates a symlink (to point to an existing object)

Symlink cannot point to another symlink. When creating a symlink, it does not check the existence of the target file, and does not check if the target file is symlink. Neither it checks the caller's permission on the target file. All these checks are deferred to the actual GetObject call via this symlink. If trying to add an existing file, as long as the caller has the write permission, the existing one will be overwritten. If the x-oss-meta- is specified, it will be added as the metadata of the symlink file.

symObjectKey the symlink object's key. targetObjectKey the target object key to point to.

error it's nil if no error, otherwise it's an error object.

func (Bucket) RestoreObject Uses

func (bucket Bucket) RestoreObject(objectKey string) error

RestoreObject restores the object from the archive storage.

An archive object is in cold status by default and it cannot be accessed. When restore is called on the cold object, it will become available for access after some time. If multiple restores are called on the same file when the object is being restored, server side does nothing for additional calls but returns success. By default, the restored object is available for access for one day. After that it will be unavailable again. But if another RestoreObject are called after the file is restored, then it will extend one day's access time of that object, up to 7 days.

objectKey object key to restore.

error it's nil if no error, otherwise it's an error object.

func (Bucket) SetObjectACL Uses

func (bucket Bucket) SetObjectACL(objectKey string, objectACL ACLType) error

SetObjectACL updates the object's ACL.

Only the bucket's owner could update object's ACL which priority is higher than bucket's ACL. For example, if the bucket ACL is private and object's ACL is public-read-write. Then object's ACL is used and it means all users could read or write that object. When the object's ACL is not set, then bucket's ACL is used as the object's ACL.

Object read operations include GetObject, HeadObject, CopyObject and UploadPartCopy on the source object; Object write operations include PutObject, PostObject, AppendObject, DeleteObject, DeleteMultipleObjects, CompleteMultipartUpload and CopyObject on target object.

objectKey the target object key (to set the ACL on) objectAcl object ACL. Valid options are PrivateACL, PublicReadACL, PublicReadWriteACL.

error it's nil if no error, otherwise it's an error object.

func (Bucket) SetObjectMeta Uses

func (bucket Bucket) SetObjectMeta(objectKey string, options ...Option) error

SetObjectMeta sets the metadata of the Object.

objectKey object options options for setting the metadata. The valid options are CacheControl, ContentDisposition, ContentEncoding, Expires,

ServerSideEncryption, and custom metadata.

error it's nil if no error, otherwise it's an error object.

func (Bucket) SignURL Uses

func (bucket Bucket) SignURL(objectKey string, method HTTPMethod, expiredInSec int64, options ...Option) (string, error)

SignURL signs the URL. Users could access the object directly with this URL without getting the AK.

objectKey the target object to sign. signURLConfig the configuration for the signed URL

string returns the signed URL, when error is nil. error it's nil if no error, otherwise it's an error object.

func (Bucket) UploadFile Uses

func (bucket Bucket) UploadFile(objectKey, filePath string, partSize int64, options ...Option) error

UploadFile is multipart file upload.

objectKey the object name. filePath the local file path to upload. partSize the part size in byte. options the options for uploading object.

error it's nil if the operation succeeds, otherwise it's an error object.

func (Bucket) UploadPart Uses

func (bucket Bucket) UploadPart(imur InitiateMultipartUploadResult, reader io.Reader,
    partSize int64, partNumber int, options ...Option) (UploadPart, error)

UploadPart uploads parts

After initializing a Multipart Upload, the upload Id and object key could be used for uploading the parts. Each part has its part number (ranges from 1 to 10,000). And for each upload Id, the part number identifies the position of the part in the whole file. And thus with the same part number and upload Id, another part upload will overwrite the data. Except the last one, minimal part size is 100KB. There's no limit on the last part size.

imur the returned value of InitiateMultipartUpload. reader io.Reader the reader for the part's data. size the part size. partNumber the part number (ranges from 1 to 10,000). Invalid part number will lead to InvalidArgument error.

UploadPart the return value of the upload part. It consists of PartNumber and ETag. It's valid when error is nil. error it's nil if the operation succeeds, otherwise it's an error object.

func (Bucket) UploadPartCopy Uses

func (bucket Bucket) UploadPartCopy(imur InitiateMultipartUploadResult, srcBucketName, srcObjectKey string,
    startPosition, partSize int64, partNumber int, options ...Option) (UploadPart, error)

UploadPartCopy uploads part copy

imur the return value of InitiateMultipartUpload copySrc source Object name startPosition the part's start index in the source file partSize the part size partNumber the part number, ranges from 1 to 10,000. If it exceeds the range OSS returns InvalidArgument error. options the constraints of source object for the copy. The copy happens only when these contraints are met. Otherwise it returns error.

CopySourceIfNoneMatch, CopySourceIfModifiedSince  CopySourceIfUnmodifiedSince, check out the following link for the detail
https://help.aliyun.com/document_detail/oss/api-reference/multipart-upload/UploadPartCopy.html

UploadPart the return value consists of PartNumber and ETag. error it's nil if the operation succeeds, otherwise it's an error object.

func (Bucket) UploadPartFromFile Uses

func (bucket Bucket) UploadPartFromFile(imur InitiateMultipartUploadResult, filePath string,
    startPosition, partSize int64, partNumber int, options ...Option) (UploadPart, error)

UploadPartFromFile uploads part from the file.

imur the return value of a successful InitiateMultipartUpload. filePath the local file path to upload. startPosition the start position in the local file. partSize the part size. partNumber the part number (from 1 to 10,000)

UploadPart the return value consists of PartNumber and ETag. error it's nil if the operation succeeds, otherwise it's an error object.

type BucketInfo Uses

type BucketInfo struct {
    XMLName          xml.Name  `xml:"Bucket"`
    Name             string    `xml:"Name"`                    // Bucket name
    Location         string    `xml:"Location"`                // Bucket datacenter
    CreationDate     time.Time `xml:"CreationDate"`            // Bucket creation time
    ExtranetEndpoint string    `xml:"ExtranetEndpoint"`        // Bucket external endpoint
    IntranetEndpoint string    `xml:"IntranetEndpoint"`        // Bucket internal endpoint
    ACL              string    `xml:"AccessControlList>Grant"` // Bucket ACL
    Owner            Owner     `xml:"Owner"`                   // Bucket owner
    StorageClass     string    `xml:"StorageClass"`            // Bucket storage class
}

BucketInfo defines Bucket information

type BucketProperties Uses

type BucketProperties struct {
    XMLName      xml.Name  `xml:"Bucket"`
    Name         string    `xml:"Name"`         // Bucket name
    Location     string    `xml:"Location"`     // Bucket datacenter
    CreationDate time.Time `xml:"CreationDate"` // Bucket create time
    StorageClass string    `xml:"StorageClass"` // Bucket storage class
}

BucketProperties defines bucket properties

type CORSRule Uses

type CORSRule struct {
    XMLName       xml.Name `xml:"CORSRule"`
    AllowedOrigin []string `xml:"AllowedOrigin"` // Allowed origins. By default it's wildcard '*'
    AllowedMethod []string `xml:"AllowedMethod"` // Allowed methods
    AllowedHeader []string `xml:"AllowedHeader"` // Allowed headers
    ExposeHeader  []string `xml:"ExposeHeader"`  // Allowed response headers
    MaxAgeSeconds int      `xml:"MaxAgeSeconds"` // Max cache ages in seconds
}

CORSRule defines CORS rules

type CORSXML Uses

type CORSXML struct {
    XMLName   xml.Name   `xml:"CORSConfiguration"`
    CORSRules []CORSRule `xml:"CORSRule"` // CORS rules
}

CORSXML defines CORS configuration

type CRCCheckError Uses

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

CRCCheckError is returned when crc check is inconsistent between client and server

func (CRCCheckError) Error Uses

func (e CRCCheckError) Error() string

Error implements interface error

type Client Uses

type Client struct {
    Config *Config // OSS client configuration
    Conn   *Conn   // Send HTTP request
}

Client OSS client

func New Uses

func New(endpoint, accessKeyID, accessKeySecret string, options ...ClientOption) (*Client, error)

New creates a new client.

endpoint the OSS datacenter endpoint such as http://oss-cn-hangzhou.aliyuncs.com . accessKeyId access key Id. accessKeySecret access key secret.

Client creates the new client instance, the returned value is valid when error is nil. error it's nil if no error, otherwise it's an error object.

func (Client) Bucket Uses

func (client Client) Bucket(bucketName string) (*Bucket, error)

Bucket gets the bucket instance.

bucketName the bucket name. Bucket the bucket object, when error is nil.

error it's nil if no error, otherwise it's an error object.

func (Client) CreateBucket Uses

func (client Client) CreateBucket(bucketName string, options ...Option) error

CreateBucket creates a bucket.

bucketName the bucket name, it's globably unique and immutable. The bucket name can only consist of lowercase letters, numbers and dash ('-').

It must start with lowercase letter or number and the length can only be between 3 and 255.

options options for creating the bucket, with optional ACL. The ACL could be ACLPrivate, ACLPublicRead, and ACLPublicReadWrite. By default it's ACLPrivate.

It could also be specified with StorageClass option, which supports StorageStandard, StorageIA(infrequent access), StorageArchive.

error it's nil if no error, otherwise it's an error object.

func (Client) DeleteBucket Uses

func (client Client) DeleteBucket(bucketName string) error

DeleteBucket deletes the bucket. Only empty bucket can be deleted (no object and parts).

bucketName the bucket name.

error it's nil if no error, otherwise it's an error object.

func (Client) DeleteBucketCORS Uses

func (client Client) DeleteBucketCORS(bucketName string) error

DeleteBucketCORS deletes the bucket's static website settings.

bucketName the bucket name.

error it's nil if no error, otherwise it's an error object.

func (Client) DeleteBucketLifecycle Uses

func (client Client) DeleteBucketLifecycle(bucketName string) error

DeleteBucketLifecycle deletes the bucket's lifecycle.

bucketName the bucket name.

error it's nil if no error, otherwise it's an error object.

func (Client) DeleteBucketLogging Uses

func (client Client) DeleteBucketLogging(bucketName string) error

DeleteBucketLogging deletes the logging configuration to disable the logging on the bucket.

bucketName the bucket name to disable the logging.

error it's nil if no error, otherwise it's an error object.

func (Client) DeleteBucketWebsite Uses

func (client Client) DeleteBucketWebsite(bucketName string) error

DeleteBucketWebsite deletes the bucket's static web site settings.

bucketName the bucket name.

error it's nil if no error, otherwise it's an error object.

func (Client) GetBucketACL Uses

func (client Client) GetBucketACL(bucketName string) (GetBucketACLResult, error)

GetBucketACL gets the bucket ACL.

bucketName the bucket name.

GetBucketAclResponse the result object, and it's only valid when error is nil. error it's nil if no error, otherwise it's an error object.

func (Client) GetBucketCORS Uses

func (client Client) GetBucketCORS(bucketName string) (GetBucketCORSResult, error)

GetBucketCORS gets the bucket's CORS settings.

bucketName the bucket name. GetBucketCORSResult the result object upon successful request. It's only valid when error is nil.

error it's nil if no error, otherwise it's an error object.

func (Client) GetBucketInfo Uses

func (client Client) GetBucketInfo(bucketName string) (GetBucketInfoResult, error)

GetBucketInfo gets the bucket information.

bucketName the bucket name. GetBucketInfoResult the result object upon successful request. It's only valid when error is nil.

error it's nil if no error, otherwise it's an error object.

func (Client) GetBucketLifecycle Uses

func (client Client) GetBucketLifecycle(bucketName string) (GetBucketLifecycleResult, error)

GetBucketLifecycle gets the bucket's lifecycle settings.

bucketName the bucket name.

GetBucketLifecycleResponse the result object upon successful request. It's only valid when error is nil. error it's nil if no error, otherwise it's an error object.

func (Client) GetBucketLocation Uses

func (client Client) GetBucketLocation(bucketName string) (string, error)

GetBucketLocation gets the bucket location.

Checks out the following link for more information : https://help.aliyun.com/document_detail/oss/user_guide/oss_concept/endpoint.html

bucketName the bucket name

string bucket's datacenter location error it's nil if no error, otherwise it's an error object.

func (Client) GetBucketLogging Uses

func (client Client) GetBucketLogging(bucketName string) (GetBucketLoggingResult, error)

GetBucketLogging gets the bucket's logging settings

bucketName the bucket name GetBucketLoggingResponse the result object upon successful request. It's only valid when error is nil.

error it's nil if no error, otherwise it's an error object.

func (Client) GetBucketReferer Uses

func (client Client) GetBucketReferer(bucketName string) (GetBucketRefererResult, error)

GetBucketReferer gets the bucket's referrer white list.

bucketName the bucket name.

GetBucketRefererResponse the result object upon successful request. It's only valid when error is nil. error it's nil if no error, otherwise it's an error object.

func (Client) GetBucketWebsite Uses

func (client Client) GetBucketWebsite(bucketName string) (GetBucketWebsiteResult, error)

GetBucketWebsite gets the bucket's default page (index page) and the error page.

bucketName the bucket name

GetBucketWebsiteResponse the result object upon successful request. It's only valid when error is nil. error it's nil if no error, otherwise it's an error object.

func (Client) IsBucketExist Uses

func (client Client) IsBucketExist(bucketName string) (bool, error)

IsBucketExist checks if the bucket exists

bucketName the bucket name.

bool true if it exists, and it's only valid when error is nil. error it's nil if no error, otherwise it's an error object.

func (Client) ListBuckets Uses

func (client Client) ListBuckets(options ...Option) (ListBucketsResult, error)

ListBuckets lists buckets of the current account under the given endpoint, with optional filters.

options specifies the filters such as Prefix, Marker and MaxKeys. Prefix is the bucket name's prefix filter.

And marker makes sure the returned buckets' name are greater than it in lexicographic order.
Maxkeys limits the max keys to return, and by default it's 100 and up to 1000.
For the common usage scenario, please check out list_bucket.go in the sample.

ListBucketsResponse the response object if error is nil.

error it's nil if no error, otherwise it's an error object.

func (Client) SetBucketACL Uses

func (client Client) SetBucketACL(bucketName string, bucketACL ACLType) error

SetBucketACL sets bucket's ACL.

bucketName the bucket name bucketAcl the bucket ACL: ACLPrivate, ACLPublicRead and ACLPublicReadWrite.

error it's nil if no error, otherwise it's an error object.

func (Client) SetBucketCORS Uses

func (client Client) SetBucketCORS(bucketName string, corsRules []CORSRule) error

SetBucketCORS sets the bucket's CORS rules

For more information, please check out https://help.aliyun.com/document_detail/oss/user_guide/security_management/cors.html

bucketName the bucket name corsRules the CORS rules to set. The related sample code is in sample/bucket_cors.go.

error it's nil if no error, otherwise it's an error object.

func (Client) SetBucketLifecycle Uses

func (client Client) SetBucketLifecycle(bucketName string, rules []LifecycleRule) error

SetBucketLifecycle sets the bucket's lifecycle.

For more information, checks out following link: https://help.aliyun.com/document_detail/oss/user_guide/manage_object/object_lifecycle.html

bucketName the bucket name. rules the lifecycle rules. There're two kind of rules: absolute time expiration and relative time expiration in days and day/month/year respectively.

Check out sample/bucket_lifecycle.go for more details.

error it's nil if no error, otherwise it's an error object.

func (Client) SetBucketLogging Uses

func (client Client) SetBucketLogging(bucketName, targetBucket, targetPrefix string,
    isEnable bool) error

SetBucketLogging sets the bucket logging settings.

OSS could automatically store the access log. Only the bucket owner could enable the logging. Once enabled, OSS would save all the access log into hourly log files in a specified bucket. For more information, please check out https://help.aliyun.com/document_detail/oss/user_guide/security_management/logging.html

bucketName bucket name to enable the log. targetBucket the target bucket name to store the log files. targetPrefix the log files' prefix.

error it's nil if no error, otherwise it's an error object.

func (Client) SetBucketReferer Uses

func (client Client) SetBucketReferer(bucketName string, referers []string, allowEmptyReferer bool) error

SetBucketReferer sets the bucket's referer whitelist and the flag if allowing empty referrer.

To avoid stealing link on OSS data, OSS supports the HTTP referrer header. A whitelist referrer could be set either by API or web console, as well as the allowing empty referrer flag. Note that this applies to requests from webbrowser only. For example, for a bucket os-example and its referrer http://www.aliyun.com, all requests from this URL could access the bucket. For more information, please check out this link : https://help.aliyun.com/document_detail/oss/user_guide/security_management/referer.html

bucketName the bucket name. referers the referrer white list. A bucket could have a referrer list and each referrer supports one '*' and multiple '?' as wildcards.

The sample could be found in sample/bucket_referer.go

allowEmptyReferer the flag of allowing empty referrer. By default it's true.

error it's nil if no error, otherwise it's an error object.

func (Client) SetBucketWebsite Uses

func (client Client) SetBucketWebsite(bucketName, indexDocument, errorDocument string) error

SetBucketWebsite sets the bucket's static website's index and error page.

OSS supports static web site hosting for the bucket data. When the bucket is enabled with that, you can access the file in the bucket like the way to access a static website. For more information, please check out: https://help.aliyun.com/document_detail/oss/user_guide/static_host_website.html

bucketName the bucket name to enable static web site. indexDocument index page. errorDocument error page.

error it's nil if no error, otherwise it's an error object.

type ClientOption Uses

type ClientOption func(*Client)

ClientOption client option such as UseCname, Timeout, SecurityToken.

func AuthProxy Uses

func AuthProxy(proxyHost, proxyUser, proxyPassword string) ClientOption

AuthProxy sets the proxy information with user name and password.

proxyHost the proxy host in the format "host:port". For example, proxy.com:80 . proxyUser the proxy user name. proxyPassword the proxy password.

func EnableCRC Uses

func EnableCRC(isEnableCRC bool) ClientOption

EnableCRC enables the CRC checksum. Default is true.

isEnableCRC true: enable CRC checksum; false: disable the CRC checksum.

func EnableMD5 Uses

func EnableMD5(isEnableMD5 bool) ClientOption

EnableMD5 enables MD5 validation.

isEnableMD5 true: enable MD5 validation; false: disable MD5 validation.

func MD5ThresholdCalcInMemory Uses

func MD5ThresholdCalcInMemory(threshold int64) ClientOption

MD5ThresholdCalcInMemory sets the memory usage threshold for computing the MD5, default is 16MB.

threshold the memory threshold in bytes. When the uploaded content is more than 16MB, the temp file is used for computing the MD5.

func Proxy Uses

func Proxy(proxyHost string) ClientOption

Proxy sets the proxy (optional). The default is not using proxy.

proxyHost the proxy host in the format "host:port". For example, proxy.com:80 .

func SecurityToken Uses

func SecurityToken(token string) ClientOption

SecurityToken sets the temporary user's SecurityToken.

token STS token

func Timeout Uses

func Timeout(connectTimeoutSec, readWriteTimeout int64) ClientOption

Timeout sets the HTTP timeout in seconds.

connectTimeoutSec HTTP timeout in seconds. Default is 10 seconds. 0 means infinite (not recommended) readWriteTimeout HTTP read or write's timeout in seconds. Default is 20 seconds. 0 means infinite.

func UseCname Uses

func UseCname(isUseCname bool) ClientOption

UseCname sets the flag of using CName. By default it's false.

isUseCname true: the endpoint has the CName, false: the endpoint does not have cname. Default is false.

func UserAgent Uses

func UserAgent(userAgent string) ClientOption

UserAgent specifies UserAgent. The default is aliyun-sdk-go/1.2.0 (windows/-/amd64;go1.5.2).

userAgent the user agent string.

type CompleteMultipartUploadResult Uses

type CompleteMultipartUploadResult struct {
    XMLName  xml.Name `xml:"CompleteMultipartUploadResult"`
    Location string   `xml:"Location"` // Object URL
    Bucket   string   `xml:"Bucket"`   // Bucket name
    ETag     string   `xml:"ETag"`     // Object ETag
    Key      string   `xml:"Key"`      // Object name
}

CompleteMultipartUploadResult defines result object of CompleteMultipartUploadRequest

type Config Uses

type Config struct {
    Endpoint        string      // OSS endpoint
    AccessKeyID     string      // AccessId
    AccessKeySecret string      // AccessKey
    RetryTimes      uint        // Retry count by default it's 5.
    UserAgent       string      // SDK name/version/system information
    IsDebug         bool        // Enable debug mode. Default is false.
    Timeout         uint        // Timeout in seconds. By default it's 60.
    SecurityToken   string      // STS Token
    IsCname         bool        // If cname is in the endpoint.
    HTTPTimeout     HTTPTimeout // HTTP timeout
    IsUseProxy      bool        // Flag of using proxy.
    ProxyHost       string      // Flag of using proxy host.
    IsAuthProxy     bool        // Flag of needing authentication.
    ProxyUser       string      // Proxy user
    ProxyPassword   string      // Proxy password
    IsEnableMD5     bool        // Flag of enabling MD5 for upload.
    MD5Threshold    int64       // Memory footprint threshold for each MD5 computation (16MB is the default), in byte. When the data is more than that, temp file is used.
    IsEnableCRC     bool        // Flag of enabling CRC for upload.
}

Config defines oss configuration

type Conn Uses

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

Conn defines OSS Conn

func (Conn) Do Uses

func (conn Conn) Do(method, bucketName, objectName string, params map[string]interface{}, headers map[string]string,
    data io.Reader, initCRC uint64, listener ProgressListener) (*Response, error)

Do sends request and returns the response

func (Conn) DoURL Uses

func (conn Conn) DoURL(method HTTPMethod, signedURL string, headers map[string]string,
    data io.Reader, initCRC uint64, listener ProgressListener) (*Response, error)

DoURL sends the request with signed URL and returns the response result.

type CopyObjectResult Uses

type CopyObjectResult struct {
    XMLName      xml.Name  `xml:"CopyObjectResult"`
    LastModified time.Time `xml:"LastModified"` // New object's last modified time.
    ETag         string    `xml:"ETag"`         // New object's ETag
}

CopyObjectResult defines result object of CopyObject

type DeleteObject Uses

type DeleteObject struct {
    XMLName xml.Name `xml:"Object"`
    Key     string   `xml:"Key"` // Object name
}

DeleteObject defines the struct for deleting object

type DeleteObjectsResult Uses

type DeleteObjectsResult struct {
    XMLName        xml.Name `xml:"DeleteResult"`
    DeletedObjects []string `xml:"Deleted>Key"` // Deleted object list
}

DeleteObjectsResult defines result of DeleteObjects request

type ErrorDocument Uses

type ErrorDocument struct {
    XMLName xml.Name `xml:"ErrorDocument"`
    Key     string   `xml:"Key"` // 404 error file name
}

ErrorDocument defines the 404 error page info

type FileChunk Uses

type FileChunk struct {
    Number int   // Chunk number
    Offset int64 // Chunk offset
    Size   int64 // Chunk size.
}

FileChunk is the file chunk definition

func SplitFileByPartNum Uses

func SplitFileByPartNum(fileName string, chunkNum int) ([]FileChunk, error)

SplitFileByPartNum splits big file into parts by the num of parts. Split the file with specified parts count, returns the split result when error is nil.

func SplitFileByPartSize Uses

func SplitFileByPartSize(fileName string, chunkSize int64) ([]FileChunk, error)

SplitFileByPartSize splits big file into parts by the size of parts. Splits the file by the part size. Returns the FileChunk when error is nil.

type GetBucketACLResult Uses

type GetBucketACLResult struct {
    XMLName xml.Name `xml:"AccessControlPolicy"`
    ACL     string   `xml:"AccessControlList>Grant"` // Bucket ACL
    Owner   Owner    `xml:"Owner"`                   // Bucket owner
}

GetBucketACLResult defines GetBucketACL request's result

type GetBucketCORSResult Uses

type GetBucketCORSResult CORSXML

GetBucketCORSResult defines the result from GetBucketCORS request.

type GetBucketInfoResult Uses

type GetBucketInfoResult struct {
    XMLName    xml.Name   `xml:"BucketInfo"`
    BucketInfo BucketInfo `xml:"Bucket"`
}

GetBucketInfoResult defines the result from GetBucketInfo request.

type GetBucketLifecycleResult Uses

type GetBucketLifecycleResult LifecycleConfiguration

GetBucketLifecycleResult defines GetBucketLifecycle's result object

type GetBucketLoggingResult Uses

type GetBucketLoggingResult LoggingXML

GetBucketLoggingResult defines the result from GetBucketLogging request

type GetBucketRefererResult Uses

type GetBucketRefererResult RefererXML

GetBucketRefererResult defines result object for GetBucketReferer request

type GetBucketWebsiteResult Uses

type GetBucketWebsiteResult WebsiteXML

GetBucketWebsiteResult defines the result from GetBucketWebsite request.

type GetObjectACLResult Uses

type GetObjectACLResult GetBucketACLResult

GetObjectACLResult defines result of GetObjectACL request

type GetObjectRequest Uses

type GetObjectRequest struct {
    ObjectKey string
}

GetObjectRequest is the request of DoGetObject

type GetObjectResult Uses

type GetObjectResult struct {
    Response  *Response
    ClientCRC hash.Hash64
    ServerCRC uint64
}

GetObjectResult is the result of DoGetObject

type HTTPMethod Uses

type HTTPMethod string

HTTPMethod HTTP request method

const (
    // HTTPGet HTTP GET
    HTTPGet HTTPMethod = "GET"

    // HTTPPut HTTP PUT
    HTTPPut HTTPMethod = "PUT"

    // HTTPHead HTTP HEAD
    HTTPHead HTTPMethod = "HEAD"

    // HTTPPost HTTP POST
    HTTPPost HTTPMethod = "POST"

    // HTTPDelete HTTP DELETE
    HTTPDelete HTTPMethod = "DELETE"
)

type HTTPTimeout Uses

type HTTPTimeout struct {
    ConnectTimeout   time.Duration
    ReadWriteTimeout time.Duration
    HeaderTimeout    time.Duration
    LongTimeout      time.Duration
    IdleConnTimeout  time.Duration
}

HTTPTimeout defines HTTP timeout.

type IndexDocument Uses

type IndexDocument struct {
    XMLName xml.Name `xml:"IndexDocument"`
    Suffix  string   `xml:"Suffix"` // The file name for the index page
}

IndexDocument defines the index page info

type InitiateMultipartUploadResult Uses

type InitiateMultipartUploadResult struct {
    XMLName  xml.Name `xml:"InitiateMultipartUploadResult"`
    Bucket   string   `xml:"Bucket"`   // Bucket name
    Key      string   `xml:"Key"`      // Object name to upload
    UploadID string   `xml:"UploadId"` // Generated UploadId
}

InitiateMultipartUploadResult defines result of InitiateMultipartUpload request

type LifecycleConfiguration Uses

type LifecycleConfiguration struct {
    XMLName xml.Name        `xml:"LifecycleConfiguration"`
    Rules   []LifecycleRule `xml:"Rule"`
}

LifecycleConfiguration is the Bucket Lifecycle configuration

type LifecycleExpiration Uses

type LifecycleExpiration struct {
    XMLName xml.Name  `xml:"Expiration"`
    Days    int       `xml:"Days,omitempty"` // Relative expiration time: The expiration time in days after the last modified time
    Date    time.Time `xml:"Date,omitempty"` // Absolute expiration time: The expiration time in date.
}

LifecycleExpiration defines the rule's expiration property

type LifecycleRule Uses

type LifecycleRule struct {
    XMLName    xml.Name            `xml:"Rule"`
    ID         string              `xml:"ID"`         // The rule ID
    Prefix     string              `xml:"Prefix"`     // The object key prefix
    Status     string              `xml:"Status"`     // The rule status (enabled or not)
    Expiration LifecycleExpiration `xml:"Expiration"` // The expiration property
}

LifecycleRule defines Lifecycle rules

func BuildLifecycleRuleByDate Uses

func BuildLifecycleRuleByDate(id, prefix string, status bool, year, month, day int) LifecycleRule

BuildLifecycleRuleByDate builds a lifecycle rule with specified expiration time.

func BuildLifecycleRuleByDays Uses

func BuildLifecycleRuleByDays(id, prefix string, status bool, days int) LifecycleRule

BuildLifecycleRuleByDays builds a lifecycle rule with specified expiration days

type ListBucketsResult Uses

type ListBucketsResult struct {
    XMLName     xml.Name           `xml:"ListAllMyBucketsResult"`
    Prefix      string             `xml:"Prefix"`         // The prefix in this query
    Marker      string             `xml:"Marker"`         // The marker filter
    MaxKeys     int                `xml:"MaxKeys"`        // The max entry count to return. This information is returned when IsTruncated is true.
    IsTruncated bool               `xml:"IsTruncated"`    // Flag true means there's remaining buckets to return.
    NextMarker  string             `xml:"NextMarker"`     // The marker filter for the next list call
    Owner       Owner              `xml:"Owner"`          // The owner information
    Buckets     []BucketProperties `xml:"Buckets>Bucket"` // The bucket list
}

ListBucketsResult defines the result object from ListBuckets request

type ListMultipartUploadResult Uses

type ListMultipartUploadResult struct {
    XMLName            xml.Name            `xml:"ListMultipartUploadsResult"`
    Bucket             string              `xml:"Bucket"`                // Bucket name
    Delimiter          string              `xml:"Delimiter"`             // Delimiter for grouping object.
    Prefix             string              `xml:"Prefix"`                // Object prefix
    KeyMarker          string              `xml:"KeyMarker"`             // Object key marker
    UploadIDMarker     string              `xml:"UploadIdMarker"`        // UploadId marker
    NextKeyMarker      string              `xml:"NextKeyMarker"`         // Next key marker, if not all entries returned.
    NextUploadIDMarker string              `xml:"NextUploadIdMarker"`    // Next uploadId marker, if not all entries returned.
    MaxUploads         int                 `xml:"MaxUploads"`            // Max uploads to return
    IsTruncated        bool                `xml:"IsTruncated"`           // Flag indicates all entries are returned.
    Uploads            []UncompletedUpload `xml:"Upload"`                // Ongoing uploads (not completed, not aborted)
    CommonPrefixes     []string            `xml:"CommonPrefixes>Prefix"` // Common prefixes list.
}

ListMultipartUploadResult defines result object of ListMultipartUpload

type ListObjectsResult Uses

type ListObjectsResult struct {
    XMLName        xml.Name           `xml:"ListBucketResult"`
    Prefix         string             `xml:"Prefix"`                // The object prefix
    Marker         string             `xml:"Marker"`                // The marker filter.
    MaxKeys        int                `xml:"MaxKeys"`               // Max keys to return
    Delimiter      string             `xml:"Delimiter"`             // The delimiter for grouping objects' name
    IsTruncated    bool               `xml:"IsTruncated"`           // Flag indicates if all results are returned (when it's false)
    NextMarker     string             `xml:"NextMarker"`            // The start point of the next query
    Objects        []ObjectProperties `xml:"Contents"`              // Object list
    CommonPrefixes []string           `xml:"CommonPrefixes>Prefix"` // You can think of commonprefixes as "folders" whose names end with the delimiter
}

ListObjectsResult defines the result from ListObjects request

type ListUploadedPartsResult Uses

type ListUploadedPartsResult struct {
    XMLName              xml.Name       `xml:"ListPartsResult"`
    Bucket               string         `xml:"Bucket"`               // Bucket name
    Key                  string         `xml:"Key"`                  // Object name
    UploadID             string         `xml:"UploadId"`             // Upload ID
    NextPartNumberMarker string         `xml:"NextPartNumberMarker"` // Next part number
    MaxParts             int            `xml:"MaxParts"`             // Max parts count
    IsTruncated          bool           `xml:"IsTruncated"`          // Flag indicates all entries returned.false: all entries returned.
    UploadedParts        []UploadedPart `xml:"Part"`                 // Uploaded parts
}

ListUploadedPartsResult defines result object of ListUploadedParts

type LoggingEnabled Uses

type LoggingEnabled struct {
    XMLName      xml.Name `xml:"LoggingEnabled"`
    TargetBucket string   `xml:"TargetBucket"` // The bucket name for storing the log files
    TargetPrefix string   `xml:"TargetPrefix"` // The log file prefix
}

LoggingEnabled defines the logging configuration information

type LoggingXML Uses

type LoggingXML struct {
    XMLName        xml.Name       `xml:"BucketLoggingStatus"`
    LoggingEnabled LoggingEnabled `xml:"LoggingEnabled"` // The logging configuration information
}

LoggingXML defines logging configuration

type MetadataDirectiveType Uses

type MetadataDirectiveType string

MetadataDirectiveType specifying whether use the metadata of source object when copying object.

const (
    // MetaCopy the target object's metadata is copied from the source one
    MetaCopy MetadataDirectiveType = "COPY"

    // MetaReplace the target object's metadata is created as part of the copy request (not same as the source one)
    MetaReplace MetadataDirectiveType = "REPLACE"
)

type ObjectProperties Uses

type ObjectProperties struct {
    XMLName      xml.Name  `xml:"Contents"`
    Key          string    `xml:"Key"`          // Object key
    Type         string    `xml:"Type"`         // Object type
    Size         int64     `xml:"Size"`         // Object size
    ETag         string    `xml:"ETag"`         // Object ETag
    Owner        Owner     `xml:"Owner"`        // Object owner information
    LastModified time.Time `xml:"LastModified"` // Object last modified time
    StorageClass string    `xml:"StorageClass"` // Object storage class (Standard, IA, Archive)
}

ObjectProperties defines Objecct properties

type Option Uses

type Option func(map[string]optionValue) error

Option HTTP option

func ACL Uses

func ACL(acl ACLType) Option

ACL is an option to set X-Oss-Acl header

func AcceptEncoding Uses

func AcceptEncoding(value string) Option

AcceptEncoding is an option to set Accept-Encoding header

func CacheControl Uses

func CacheControl(value string) Option

CacheControl is an option to set Cache-Control header

func Checkpoint Uses

func Checkpoint(isEnable bool, filePath string) Option

Checkpoint sets the isEnable flag and checkpoint file path for DownloadFile/UploadFile.

func ContentDisposition Uses

func ContentDisposition(value string) Option

ContentDisposition is an option to set Content-Disposition header

func ContentEncoding Uses

func ContentEncoding(value string) Option

ContentEncoding is an option to set Content-Encoding header

func ContentLength Uses

func ContentLength(length int64) Option

ContentLength is an option to set Content-Length header

func ContentMD5 Uses

func ContentMD5(value string) Option

ContentMD5 is an option to set Content-MD5 header

func ContentType Uses

func ContentType(value string) Option

ContentType is an option to set Content-Type header

func CopySource Uses

func CopySource(sourceBucket, sourceObject string) Option

CopySource is an option to set X-Oss-Copy-Source header

func CopySourceIfMatch Uses

func CopySourceIfMatch(value string) Option

CopySourceIfMatch is an option to set X-Oss-Copy-Source-If-Match header

func CopySourceIfModifiedSince Uses

func CopySourceIfModifiedSince(t time.Time) Option

CopySourceIfModifiedSince is an option to set X-Oss-CopySource-If-Modified-Since header

func CopySourceIfNoneMatch Uses

func CopySourceIfNoneMatch(value string) Option

CopySourceIfNoneMatch is an option to set X-Oss-Copy-Source-If-None-Match header

func CopySourceIfUnmodifiedSince Uses

func CopySourceIfUnmodifiedSince(t time.Time) Option

CopySourceIfUnmodifiedSince is an option to set X-Oss-Copy-Source-If-Unmodified-Since header

func CopySourceRange Uses

func CopySourceRange(startPosition, partSize int64) Option

CopySourceRange is an option to set X-Oss-Copy-Source header

func DeleteObjectsQuiet Uses

func DeleteObjectsQuiet(isQuiet bool) Option

DeleteObjectsQuiet false:DeleteObjects in verbose mode; true:DeleteObjects in quite mode. Default is false.

func Delimiter Uses

func Delimiter(value string) Option

Delimiter is an option to set delimiler parameter

func EncodingType Uses

func EncodingType(value string) Option

EncodingType is an option to set encoding-type parameter

func Expires Uses

func Expires(t time.Time) Option

Expires is an option to set Expires header

func IfMatch Uses

func IfMatch(value string) Option

IfMatch is an option to set If-Match header

func IfModifiedSince Uses

func IfModifiedSince(t time.Time) Option

IfModifiedSince is an option to set If-Modified-Since header

func IfNoneMatch Uses

func IfNoneMatch(value string) Option

IfNoneMatch is an option to set IfNoneMatch header

func IfUnmodifiedSince Uses

func IfUnmodifiedSince(t time.Time) Option

IfUnmodifiedSince is an option to set If-Unmodified-Since header

func InitCRC Uses

func InitCRC(initCRC uint64) Option

InitCRC Init AppendObject CRC

func KeyMarker Uses

func KeyMarker(value string) Option

KeyMarker is an option to set key-marker parameter

func Marker Uses

func Marker(value string) Option

Marker is an option to set marker parameter

func MaxKeys Uses

func MaxKeys(value int) Option

MaxKeys is an option to set maxkeys parameter

func MaxUploads Uses

func MaxUploads(value int) Option

MaxUploads is an option to set max-uploads parameter

func Meta Uses

func Meta(key, value string) Option

Meta is an option to set Meta header

func MetadataDirective Uses

func MetadataDirective(directive MetadataDirectiveType) Option

MetadataDirective is an option to set X-Oss-Metadata-Directive header

func NormalizedRange Uses

func NormalizedRange(nr string) Option

NormalizedRange is an option to set Range header, such as 1024-2048 or 1024- or -2048

func ObjectACL Uses

func ObjectACL(acl ACLType) Option

ObjectACL is an option to set X-Oss-Object-Acl header

func Origin Uses

func Origin(value string) Option

Origin is an option to set Origin header

func Prefix Uses

func Prefix(value string) Option

Prefix is an option to set prefix parameter

func Process Uses

func Process(value string) Option

Process is an option to set X-Oss-Process param

func Progress Uses

func Progress(listener ProgressListener) Option

Progress set progress listener

func Range Uses

func Range(start, end int64) Option

Range is an option to set Range header, [start, end]

func ResponseCacheControl Uses

func ResponseCacheControl(value string) Option

ResponseCacheControl is an option to set response-cache-control param

func ResponseContentDisposition Uses

func ResponseContentDisposition(value string) Option

ResponseContentDisposition is an option to set response-content-disposition param

func ResponseContentEncoding Uses

func ResponseContentEncoding(value string) Option

ResponseContentEncoding is an option to set response-content-encoding param

func ResponseContentLanguage Uses

func ResponseContentLanguage(value string) Option

ResponseContentLanguage is an option to set response-content-language param

func ResponseContentType Uses

func ResponseContentType(value string) Option

ResponseContentType is an option to set response-content-type param

func ResponseExpires Uses

func ResponseExpires(value string) Option

ResponseExpires is an option to set response-expires param

func Routines Uses

func Routines(n int) Option

Routines DownloadFile/UploadFile routine count

func ServerSideEncryption Uses

func ServerSideEncryption(value string) Option

ServerSideEncryption is an option to set X-Oss-Server-Side-Encryption header

func StorageClass Uses

func StorageClass(value StorageClassType) Option

StorageClass bucket storage class

func UploadIDMarker Uses

func UploadIDMarker(value string) Option

UploadIDMarker is an option to set upload-id-marker parameter

type Owner Uses

type Owner struct {
    XMLName     xml.Name `xml:"Owner"`
    ID          string   `xml:"ID"`          // Owner ID
    DisplayName string   `xml:"DisplayName"` // Owner's display name
}

Owner defines Bucket/Object's owner

type ProgressEvent Uses

type ProgressEvent struct {
    ConsumedBytes int64
    TotalBytes    int64
    EventType     ProgressEventType
}

ProgressEvent defines progress event

type ProgressEventType Uses

type ProgressEventType int

ProgressEventType defines transfer progress event type

const (
    // TransferStartedEvent transfer started, set TotalBytes
    TransferStartedEvent ProgressEventType = 1 + iota
    // TransferDataEvent transfer data, set ConsumedBytes anmd TotalBytes
    TransferDataEvent
    // TransferCompletedEvent transfer completed
    TransferCompletedEvent
    // TransferFailedEvent transfer encounters an error
    TransferFailedEvent
)

type ProgressListener Uses

type ProgressListener interface {
    ProgressChanged(event *ProgressEvent)
}

ProgressListener listens progress change

type PutObjectRequest Uses

type PutObjectRequest struct {
    ObjectKey string
    Reader    io.Reader
}

PutObjectRequest is the request of DoPutObject

type RefererXML Uses

type RefererXML struct {
    XMLName           xml.Name `xml:"RefererConfiguration"`
    AllowEmptyReferer bool     `xml:"AllowEmptyReferer"`   // Allow empty referrer
    RefererList       []string `xml:"RefererList>Referer"` // Referer whitelist
}

RefererXML defines Referer configuration

type Response Uses

type Response struct {
    StatusCode int
    Headers    http.Header
    Body       io.ReadCloser
    ClientCRC  uint64
    ServerCRC  uint64
}

Response defines HTTP response from OSS

type ServiceError Uses

type ServiceError struct {
    XMLName    xml.Name `xml:"Error"`
    Code       string   `xml:"Code"`      // The error code returned from OSS to the caller
    Message    string   `xml:"Message"`   // The detail error message from OSS
    RequestID  string   `xml:"RequestId"` // The UUID used to uniquely identify the request
    HostID     string   `xml:"HostId"`    // The OSS server cluster's Id
    RawMessage string   // The raw messages from OSS
    StatusCode int      // HTTP status code
}

ServiceError contains fields of the error response from Oss Service REST API.

func (ServiceError) Error Uses

func (e ServiceError) Error() string

Error implements interface error

type StorageClassType Uses

type StorageClassType string

StorageClassType bucket storage type

const (
    // StorageStandard standard
    StorageStandard StorageClassType = "Standard"

    // StorageIA infrequent access
    StorageIA StorageClassType = "IA"

    // StorageArchive archive
    StorageArchive StorageClassType = "Archive"
)

type UncompletedUpload Uses

type UncompletedUpload struct {
    XMLName   xml.Name  `xml:"Upload"`
    Key       string    `xml:"Key"`       // Object name
    UploadID  string    `xml:"UploadId"`  // The UploadId
    Initiated time.Time `xml:"Initiated"` // Initialization time in the format such as 2012-02-23T04:18:23.000Z
}

UncompletedUpload structure wraps an uncompleted upload task

type UnexpectedStatusCodeError Uses

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

UnexpectedStatusCodeError is returned when a storage service responds with neither an error nor with an HTTP status code indicating success.

func (UnexpectedStatusCodeError) Error Uses

func (e UnexpectedStatusCodeError) Error() string

Error implements interface error

func (UnexpectedStatusCodeError) Got Uses

func (e UnexpectedStatusCodeError) Got() int

Got is the actual status code returned by oss.

type UploadPart Uses

type UploadPart struct {
    XMLName    xml.Name `xml:"Part"`
    PartNumber int      `xml:"PartNumber"` // Part number
    ETag       string   `xml:"ETag"`       // ETag value of the part's data
}

UploadPart defines the upload/copy part

type UploadPartCopyResult Uses

type UploadPartCopyResult struct {
    XMLName      xml.Name  `xml:"CopyPartResult"`
    LastModified time.Time `xml:"LastModified"` // Last modified time
    ETag         string    `xml:"ETag"`         // ETag
}

UploadPartCopyResult defines result object of multipart copy request.

type UploadPartRequest Uses

type UploadPartRequest struct {
    InitResult *InitiateMultipartUploadResult
    Reader     io.Reader
    PartSize   int64
    PartNumber int
}

UploadPartRequest is the request of DoUploadPart

type UploadPartResult Uses

type UploadPartResult struct {
    Part UploadPart
}

UploadPartResult is the result of DoUploadPart

type UploadedPart Uses

type UploadedPart struct {
    XMLName      xml.Name  `xml:"Part"`
    PartNumber   int       `xml:"PartNumber"`   // Part number
    LastModified time.Time `xml:"LastModified"` // Last modified time
    ETag         string    `xml:"ETag"`         // ETag cache
    Size         int       `xml:"Size"`         // Part size
}

UploadedPart defines uploaded part

type WebsiteXML Uses

type WebsiteXML struct {
    XMLName       xml.Name      `xml:"WebsiteConfiguration"`
    IndexDocument IndexDocument `xml:"IndexDocument"` // The index page
    ErrorDocument ErrorDocument `xml:"ErrorDocument"` // The error page
}

WebsiteXML defines Website configuration

Package oss imports 26 packages (graph) and is imported by 22 packages. Updated 2018-06-15. Refresh now. Tools for package owners.