Documentation ¶
Overview ¶
Package oss implements a library for Aliyun Object Storage Service.
Index ¶
- Constants
- Variables
- func CanonicalizedHeaders(header http.Header) string
- func CanonicalizedResource(u *url.URL) string
- func FormatRange(first, length int64) (r string)
- func GetDomain(location string, internal bool) (domain string)
- func HmacSha1(secret, data string) string
- func HmacSha256(secret, data string) string
- func HmacX(secret, data string, h func() hash.Hash) string
- func IsBucketName(name string) bool
- func IsObjectName(name string) bool
- func Md5sum(data []byte) string
- func ParseContentRange(cr string) (first int64, length int64, total int64, err error)
- func ReadBody(res *http.Response, v interface{}) error
- type AccessControlPolicy
- type Bucket
- func (b Bucket) Delete(args ...Params) error
- func (b Bucket) DeleteCORS(args ...Params) error
- func (b Bucket) DeleteLifecycle(args ...Params) error
- func (b Bucket) DeleteLogging(args ...Params) error
- func (b Bucket) DeleteObjects(keys []string, quiet bool, args ...Params) ([]string, error)
- func (b Bucket) DeleteWebsite(args ...Params) error
- func (b Bucket) Do(method, object string, body, v interface{}, args ...Params) error
- func (b Bucket) GetACL(args ...Params) (string, error)
- func (b Bucket) GetCORS(args ...Params) (*CORSConfiguration, error)
- func (b Bucket) GetLifecycle(args ...Params) (*LifecycleConfiguration, error)
- func (b Bucket) GetLocation(args ...Params) (string, error)
- func (b Bucket) GetLogging(args ...Params) (*BucketLoggingStatus, error)
- func (b Bucket) GetReferer(args ...Params) (*RefererConfiguration, error)
- func (b Bucket) GetRequest(method, object string, body interface{}, args ...Params) (*http.Request, error)
- func (b Bucket) GetResponse(method, object string, body interface{}, args ...Params) (*http.Response, error)
- func (b Bucket) GetWebsite(args ...Params) (*WebsiteConfiguration, error)
- func (b Bucket) ListMultipartUploads(args ...Params) (*ListMultipartUploadsResult, error)
- func (b Bucket) ListObject(args ...Params) (*ListBucketResult, error)
- func (b Bucket) NewObject(objectName string) Object
- func (b Bucket) Put(args ...Params) error
- func (b Bucket) PutACL(args ...Params) error
- func (b Bucket) PutCORS(cfg CORSConfiguration, args ...Params) error
- func (b Bucket) PutLifecycle(lc LifecycleConfiguration, args ...Params) error
- func (b Bucket) PutLogging(bls BucketLoggingStatus, args ...Params) error
- func (b Bucket) PutReferer(rc RefererConfiguration, args ...Params) error
- func (b Bucket) PutWebsite(wc WebsiteConfiguration, args ...Params) error
- type BucketLoggingStatus
- type CORSConfiguration
- type CORSRule
- type CompleteMultipartUpload
- type CompleteMultipartUploadPart
- type CompleteMultipartUploadResult
- type CopyObjectResult
- type CopyPartResult
- type CreateBucketConfiguration
- type Delete
- type DeleteObject
- type DeleteResult
- type Error
- type GetObjectInfoResult
- type InitiateMultipartUploadResult
- type LifecycleConfiguration
- type LifecycleRule
- type ListAllMyBucketsResult
- type ListBucketResult
- type ListMultipartUploadsResult
- type ListPartsResult
- type Object
- func (o Object) AbortMultipartUpload(uploadId string, args ...Params) error
- func (o Object) Append(position int64, data interface{}, args ...Params) (next int64, crc, etag string, err error)
- func (o Object) CompleteMultipartUpload(uploadId string, parts CompleteMultipartUpload, args ...Params) (*CompleteMultipartUploadResult, error)
- func (o Object) Copy(source Object, args ...Params) (*CopyObjectResult, error)
- func (o Object) Delete(args ...Params) error
- func (o Object) Do(method string, body, v interface{}, args ...Params) error
- func (o Object) FullName() string
- func (o Object) Get(data interface{}, args ...Params) error
- func (o Object) GetACL(args ...Params) (string, error)
- func (o Object) GetInfo(args ...Params) (*GetObjectInfoResult, error)
- func (o Object) GetRequest(method string, body interface{}, args ...Params) (*http.Request, error)
- func (o Object) GetResponse(method string, body interface{}, args ...Params) (*http.Response, error)
- func (o Object) Head(args ...Params) (http.Header, error)
- func (o Object) InitiateMultipartUpload(args ...Params) (*InitiateMultipartUploadResult, error)
- func (o Object) ListParts(uploadId string, args ...Params) (*ListPartsResult, error)
- func (o Object) Options(args ...Params) (http.Header, error)
- func (o Object) Put(data interface{}, args ...Params) (string, error)
- func (o Object) PutACL(args ...Params) error
- func (o Object) Range(first, length int64, data interface{}, args ...Params) (int64, int64, error)
- func (o Object) UploadPart(partNumber int, uploadId string, data interface{}, args ...Params) (string, error)
- func (o Object) UploadPartCopy(partNumber int, uploadId string, source Object, args ...Params) (*CopyPartResult, error)
- type Owner
- type Params
- type RefererConfiguration
- type Service
- func (s Service) Do(method, bucket, object string, body, v interface{}, args ...Params) error
- func (s Service) GetRequest(method, bucket, object string, body interface{}, args ...Params) (*http.Request, error)
- func (s Service) GetResponse(method, bucket, object string, body interface{}, args ...Params) (*http.Response, error)
- func (s Service) Host() string
- func (s Service) ListBucket(args ...Params) (*ListAllMyBucketsResult, error)
- func (s Service) NewBucket(bucketName string) Bucket
- func (s Service) Scheme() string
- func (s Service) Signature(req *http.Request, seconds int)
- type WebsiteConfiguration
Constants ¶
const ( ACLPublicReadWrite = "public-read-write" ACLPublicRead = "public-read" ACLPrivate = "private" )
OSS Access Control List
const ( LocationCNQingdao = "oss-cn-qingdao" LocationCNBeijing = "oss-cn-beijing" LocationCNHangzhou = "oss-cn-hangzhou" LocationCNHongkong = "oss-cn-hongkong" LocationCNShenzhen = "oss-cn-shenzhen" LocationCNShanghai = "oss-cn-shanghai" LocationUSWest1 = "oss-us-west-1" LocationAPSoutheast1 = "oss-ap-southeast-1" )
OSS Location List
const ( HeaderRange = "Range" HeaderContentRange = "Content-Range" )
Variables ¶
var ( ErrContentRangeInvalid = errors.New("content range invalid") ErrContentRangeCorrupt = errors.New("content range corrupt") )
var UserAgent = "aliyun-oss-go-sdk"
UserAgent is the default user agent and is used by GetRequest.
Functions ¶
func CanonicalizedHeaders ¶
CanonicalizedHeaders returns the canonicalized OSS headers as a string.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/access-control&signature-header
func CanonicalizedResource ¶
CanonicalizedResource returns the canonicalized OSS resource as a string.
Get the bucket name and the object name from the URL's Host and Path.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/access-control&signature-header
func FormatRange ¶
FormatRange set the Range header given first and length. It returns byte-range-spec if first >= 0, no last-byte-pos if length <= 0. It returns suffix-byte-range-spec if first < 0 and length > 0. It returns the empty string if first < 0 and length <= 0.
http://tools.ietf.org/html/draft-ietf-httpbis-p5-range-19#section-5.4
func GetDomain ¶
GetDomain returns the OSS access domain by the location, if the internal is ture returns the intranet domain.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/product-documentation/domain-region
func HmacSha256 ¶
HmacSha256 returns the base64 HMAC-SHA256 hash of the data using the given secret.
func HmacX ¶
HmacX returns the base64 HMAC-X hash of the data using the given secret.
The SHA1 is used if the given hash.Hash type is nil.
func IsBucketName ¶
IsBucketName returns true if the name is a valid bucket name.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/product-documentation/intruduction&concepts
func IsObjectName ¶
IsObjectName returns true if the name is a valid object name.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/product-documentation/intruduction&concepts
func ParseContentRange ¶
ParseContentRange parse the Content-Range header. It returns total = -1 if the instance-length is the asterisk "*" character. It returns first = length = -1 if the byte-range-resp-spec is the asterisk "*" character.
http://tools.ietf.org/html/draft-ietf-httpbis-p5-range-19#section-5.2
func ReadBody ¶
ReadBody reads the response body and stores the result in the value pointed to by v,
When the status code is 3xx, 4xx or 5xx returns the Error.
If v is nil, the response body is discarded or, if v's type is not *[]byte, *os.File and *bytes.Buffer, then decode XML to it.
Content-Encoding deflate and gzip are supported.
Types ¶
type AccessControlPolicy ¶
AccessControlPolicy contains the information of the bucket ACL.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/access-control&bucket-acl
type Bucket ¶
Bucket represents a OSS bucket, the Name is required.
func (Bucket) Delete ¶
Delete the bucket, returns BucketNotEmpty Error if the buckect is not empty.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/bucket&DeleteBucket
func (Bucket) DeleteCORS ¶
DeleteCORS close the CORS and empty the rules.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/cors&DeleteBucketcors
func (Bucket) DeleteLifecycle ¶
DeleteLifecycle remove the objects lifecycle of the bucket, after no objects will be auto deleted.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/bucket&DeleteBucketLifecycle
func (Bucket) DeleteLogging ¶
DeleteLogging close the bucket access log.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/bucket&DeleteBucketLogging
func (Bucket) DeleteObjects ¶
DeleteObjects delete multiple objects by the keys, if not quiet returns the deleted objects.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/object&DeleteMultipleObjects
func (Bucket) DeleteWebsite ¶
DeleteWebsite close the static site of the bucket.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/bucket&DeleteBucketWebsite
func (Bucket) Do ¶
Do sends an HTTP request to OSS and read the HTTP response to v.
The first optional Params is for Header, the second is for Query.
Overwritten the Service.Do with the bucket name.
func (Bucket) GetACL ¶
GetACL returns the bucket ACL.
The first optional Params is for Header, the second is for Query.
Get and record:
b.ACL, err = b.GetACL()
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/bucket&GetBucketAcl
func (Bucket) GetCORS ¶
func (b Bucket) GetCORS(args ...Params) (*CORSConfiguration, error)
GetCORS get the CROS configuration.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/cors&GetBucketcors
func (Bucket) GetLifecycle ¶
func (b Bucket) GetLifecycle(args ...Params) (*LifecycleConfiguration, error)
GetLifecycle returns the objects lifecycle configuration of the bucket.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/bucket&GetBucketLifecycle
func (Bucket) GetLocation ¶
GetLocation returns the bucket location.
The first optional Params is for Header, the second is for Query.
Get and record:
b.Location, err = b.GetLocation()
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/bucket&GetBucketLocation
func (Bucket) GetLogging ¶
func (b Bucket) GetLogging(args ...Params) (*BucketLoggingStatus, error)
GetLogging returns the logging status of the bucket.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/bucket&GetBucketLogging
func (Bucket) GetReferer ¶
func (b Bucket) GetReferer(args ...Params) (*RefererConfiguration, error)
GetReferer returns the referer white list configuration of the bucket.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/bucket&GetBucketReferer
func (Bucket) GetRequest ¶
func (b Bucket) GetRequest(method, object string, body interface{}, args ...Params) (*http.Request, error)
GetRequest returns a new http.Request given a method and optional object, body.
The first optional Params is for Header, the second is for Query.
Overwritten the Service.GetRequest with the bucket name.
func (Bucket) GetResponse ¶
func (b Bucket) GetResponse(method, object string, body interface{}, args ...Params) (*http.Response, error)
GetResponse sends an HTTP request to OSS and returns the HTTP response.
The first optional Params is for Header, the second is for Query.
Overwritten the Service.GetResponse with the bucket name.
func (Bucket) GetWebsite ¶
func (b Bucket) GetWebsite(args ...Params) (*WebsiteConfiguration, error)
GetWebsite returns the static site configuration of the bucket.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/bucket&GetBucketWebsite
func (Bucket) ListMultipartUploads ¶
func (b Bucket) ListMultipartUploads(args ...Params) (*ListMultipartUploadsResult, error)
ListMultipartUploads returns the initialized but not complete or abort Multipart Uploads.
The first optional Params is for Header, the second is for Query.
Query predefine parameters: delimiter, max-uploads, key-marker, prefix, upload-id-marker, encoding-type.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/multipart-upload&ListMultipartUploads
func (Bucket) ListObject ¶
func (b Bucket) ListObject(args ...Params) (*ListBucketResult, error)
ListObject returns the objects information of the bucket.
The first optional Params is for Header, the second is for Query.
Query predefine parameters: delimiter, marker, max-keys, prefix, encoding-type.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/bucket&GetBucket
func (Bucket) Put ¶
Put create the buckect also send the ACL and the location if they are not the empty string.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/bucket&PutBucket
func (Bucket) PutACL ¶
PutACL change the bucket acl if it is the empty string.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/bucket&PutBucketACL
func (Bucket) PutCORS ¶
func (b Bucket) PutCORS(cfg CORSConfiguration, args ...Params) error
PutCORS set the CROS configuration, replace it if already exists.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/cors&PutBucketcors
func (Bucket) PutLifecycle ¶
func (b Bucket) PutLifecycle(lc LifecycleConfiguration, args ...Params) error
PutLifecycle set the objects lifecycle of the bucket.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/bucket&PutBucketLifecycle
func (Bucket) PutLogging ¶
func (b Bucket) PutLogging(bls BucketLoggingStatus, args ...Params) error
PutLogging open the bucket access log.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/bucket&PutBucketLogging
func (Bucket) PutReferer ¶
func (b Bucket) PutReferer(rc RefererConfiguration, args ...Params) error
PutReferer set the referer white list for preventing hotlinking.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/bucket&PutBucketReferer https://docs.aliyun.com/#/pub/oss/product-documentation/function&referer-white-list
func (Bucket) PutWebsite ¶
func (b Bucket) PutWebsite(wc WebsiteConfiguration, args ...Params) error
PutWebsite set the bucket as a static site.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/bucket&PutBucketWebsite
type BucketLoggingStatus ¶
type BucketLoggingStatus struct { LoggingEnabled struct { TargetBucket string TargetPrefix string } }
BucketLoggingStatus represents the logging status.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/bucket&PutBucketLogging https://docs.aliyun.com/#/pub/oss/api-reference/bucket&GetBucketLogging
type CORSConfiguration ¶
type CORSConfiguration struct {
CORSRule []CORSRule
}
CORSConfiguration represents the CORS configuration.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/cors&PutBucketcors https://docs.aliyun.com/#/pub/oss/api-reference/cors&GetBucketcors
type CORSRule ¶
type CORSRule struct { AllowedOrigin string AllowedMethod string AllowedHeader string ExposeHeader string MaxAgeSeconds int }
CORSRule represents a rule of the CORS configuration.
type CompleteMultipartUpload ¶
type CompleteMultipartUpload struct {
Part []CompleteMultipartUploadPart
}
CompleteMultipartUpload represents all the completed parts.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/multipart-upload&CompleteMultipartUpload
type CompleteMultipartUploadPart ¶
CompleteMultipartUploadPart represents a completed part.
type CompleteMultipartUploadResult ¶
CompleteMultipartUploadResult represents the complete Multipart Upload result.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/multipart-upload&CompleteMultipartUpload
type CopyObjectResult ¶
CopyObjectResult represents the copy object result. Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/object&CopyObject
type CopyPartResult ¶
CopyPartResult represents the upload a copy part result.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/multipart-upload&UploadPartCopy
type CreateBucketConfiguration ¶
type CreateBucketConfiguration struct {
LocationConstraint string
}
CreateBucketConfiguration represents the create bucket configuration.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/bucket&PutBucket
type Delete ¶
type Delete struct { Quiet bool Object []DeleteObject }
Delete represents the delete objects.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/object&DeleteMultipleObjects
type DeleteObject ¶
type DeleteObject struct {
Key string
}
DeleteObject represents a delete object.
type DeleteResult ¶
type DeleteResult struct {
Deleted []DeleteObject
}
DeleteResult represents the delete objects result.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/object&DeleteMultipleObjects
type Error ¶
Error represents the OSS error response when the status code is 3xx, 4xx or 5xx.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/error-response
type GetObjectInfoResult ¶
type GetObjectInfoResult struct { Bucket string Type string Key string ETag string ContentType string `xml:"Content-Type"` Size int64 LastModified string // 2006-01-02T15:04:05.000Z }
GetObjectInfoResult represents the object info result.
type InitiateMultipartUploadResult ¶
InitiateMultipartUploadResult represents the initialize Multipart Upload result.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/multipart-upload&InitiateMultipartUpload
type LifecycleConfiguration ¶
type LifecycleConfiguration struct {
Rule []LifecycleRule
}
LifecycleConfiguration represents the objects lifecycle configuration.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/bucket&PutBucketLifecycle https://docs.aliyun.com/#/pub/oss/api-reference/bucket&GetBucketLifecycle
type LifecycleRule ¶
type LifecycleRule struct { ID string `xml:",omitempty"` Prefix string Status string // Enabled, Disabled Expiration struct { Date string `xml:",omitempty"` Days int `xml:",omitempty"` } }
LifecycleRule represents a rule of the objects lifecycle configuration.
type ListAllMyBucketsResult ¶
type ListAllMyBucketsResult struct { Prefix string Marker string MaxKeys string IsTruncated bool NextMarker string Owner Owner Buckets struct { Bucket []struct { Location string Name string CreationDate string } } }
ListAllMyBucketsResult represents the get service result.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/service&GetService
type ListBucketResult ¶
type ListBucketResult struct { Name string Prefix string Marker string MaxKeys string Delimiter string IsTruncated bool Contents []struct { Key string LastModified string ETag string Type string Size string StorageClass string Owner Owner } CommonPrefixes struct { Prefix string } NextMarker string EncodingType string `xml:"encoding-type,omitempty"` }
ListBucketResult represents the get bucket result.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/bucket&GetBucket
type ListMultipartUploadsResult ¶
type ListMultipartUploadsResult struct { Bucket string EncodingType string KeyMarker string UploadIdMarker string NextKeyMarker string NextUploadMarker string MaxUploads int IsTruncated bool Upload []struct { Key string UploadId string Initiated time.Time } }
ListMultipartUploadsResult represents the list Multipart Uploads result.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/multipart-upload&ListMultipartUploads
type ListPartsResult ¶
type ListPartsResult struct { Bucket string EncodingType string Key string UploadId string PartNumberMarker int NextPartNumberMarker string MaxParts int IsTruncated bool Part []struct { PartNumber int LastModified time.Time ETag string Size int } }
ListPartsResult represents the list parts result.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/multipart-upload&ListParts
type Object ¶
Object represents a OSS object, the Name is required.
func (Object) AbortMultipartUpload ¶
AbortMultipartUpload abort the Multipart Upload given a uploadId, all the already uploaded parts will be deleted.
To release all the OSS space call multiple times.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/multipart-upload&AbortMultipartUpload
func (Object) Append ¶
func (o Object) Append(position int64, data interface{}, args ...Params) (next int64, crc, etag string, err error)
Append the data to the object content, also send the ACL if it is not the empty string, returns ObjectNotAppendable Error if the object is not Appendable, returns the next append position, the hash crc64ecma and the ETag if success.
The first optional Params is for Header, the second is for Query.
The data's type must be []byte, *[]byte, *os.File, *bytes.Buffer, *bytes.Reader or *strings.Reader.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/object&AppendObject
func (Object) CompleteMultipartUpload ¶
func (o Object) CompleteMultipartUpload(uploadId string, parts CompleteMultipartUpload, args ...Params) (*CompleteMultipartUploadResult, error)
CompleteMultipartUpload complete the Multipart Upload given a uploadId, all the partNumbers and ETags.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/multipart-upload&CompleteMultipartUpload
func (Object) Copy ¶
func (o Object) Copy(source Object, args ...Params) (*CopyObjectResult, error)
Copy the object content from the source object, also send the ACL if it is not the empty string.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/object&CopyObject
func (Object) Delete ¶
Delete the object.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/object&DeleteObject
func (Object) Do ¶
Do sends an HTTP request to OSS and read the HTTP response to v.
The first optional Params is for Header, the second is for Query.
Overwritten the Bucket.Do with the object name.
func (Object) FullName ¶
FullName returns the string "/BucketName/ObjectName".
If the bucket name or the object name is invalid returns the empty string.
func (Object) Get ¶
Get the object content to the data.
The first optional Params is for Header, the second is for Query.
The data's type must be *[]byte, *os.File, *bytes.Buffer
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/object&GetObject
func (Object) GetACL ¶
GetACL returns the object ACL, if not set returns "default".
The first optional Params is for Header, the second is for Query.
Get and record:
o.ACL, err = o.GetACL()
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/object&GetObjectACL
func (Object) GetInfo ¶
func (o Object) GetInfo(args ...Params) (*GetObjectInfoResult, error)
GetInfo returns the object info.
The first optional Params is for Header, the second is for Query.
func (Object) GetRequest ¶
GetRequest returns a new http.Request given a method and body.
The first optional Params is for Header, the second is for Query.
Overwritten the Bucket.GetRequest with the object name.
func (Object) GetResponse ¶
func (o Object) GetResponse(method string, body interface{}, args ...Params) (*http.Response, error)
GetResponse sends an HTTP request to OSS and returns the HTTP response.
The first optional Params is for Header, the second is for Query.
Overwritten the Bucket.GetResponse with the object name.
func (Object) Head ¶
Head the object and returns the response header.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/object&HeadObject
func (Object) InitiateMultipartUpload ¶
func (o Object) InitiateMultipartUpload(args ...Params) (*InitiateMultipartUploadResult, error)
InitiateMultipartUpload initialize a Multipart Upload event.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/multipart-upload&InitiateMultipartUpload
func (Object) ListParts ¶
func (o Object) ListParts(uploadId string, args ...Params) (*ListPartsResult, error)
ListParts returns the already uploaded parts given a uploadId.
The first optional Params is for Header, the second is for Query.
Query predefine parameters: max-parts, part-number-marker, encoding-type.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/multipart-upload&ListParts
func (Object) Options ¶
Options the object and returns the response header.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/cors&OptionObject
func (Object) Put ¶
Put the data as the object content, also send the ACL if it is not the empty string, returns the ETag.
The first optional Params is for Header, the second is for Query.
The data's type must be []byte, *[]byte, *os.File, *bytes.Buffer, *bytes.Reader or *strings.Reader.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/object&PutObject
func (Object) PutACL ¶
PutACL change the object acl if it is the empty string.
The first optional Params is for Header, the second is for Query.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/object&PutObjectACL
func (Object) Range ¶
Range get the object range content to the data given the first-byte-pos and the length, returns the range-length and the instance-length.
The range-length is less than or equal to the given length. The first-byte-pos add the range-length equal the instance-length indicate EOF.
The first optional Params is for Header, the second is for Query.
The data's type must be *[]byte, *os.File, *bytes.Buffer
The last range must be given exact length or length <= 0, because OSS not support last-byte-pos greater than or equal to the instance-length.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/object&GetObject
func (Object) UploadPart ¶
func (o Object) UploadPart(partNumber int, uploadId string, data interface{}, args ...Params) (string, error)
UploadPart upload the data as a part given a partNumber and a uploadId returns the ETag.
The first optional Params is for Header, the second is for Query.
The partNumber must be gte 1 and lte 10000. The data's type must be []byte, *[]byte, *os.File, *bytes.Buffer, *bytes.Reader or *strings.Reader.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/multipart-upload&UploadPart
func (Object) UploadPartCopy ¶
func (o Object) UploadPartCopy(partNumber int, uploadId string, source Object, args ...Params) (*CopyPartResult, error)
UploadPartCopy upload a part copy from the source object given a partNumber and a uploadId returns the ETag.
The first optional Params is for Header, the second is for Query.
The partNumber must be gte 1 and lte 10000.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/multipart-upload&UploadPartCopy
type Params ¶
A Params represents the http.Header or the url.Values.
func (Params) Add ¶
Add adds the value to key. It appends to any existing values associated with key.
func (Params) Get ¶
Get gets the first value associated with the given key. If there are no values associated with the key, Get returns the empty string. To access multiple values, use the map directly.
type RefererConfiguration ¶
RefererConfiguration represents the referer white list configuration.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/bucket&PutBucketReferer https://docs.aliyun.com/#/pub/oss/api-reference/bucket&GetBucketReferer
type Service ¶
type Service struct { Unsafe bool Domain string AccessKeyId string AccessKeySecret string SecurityToken string // STS }
Service represents Aliyun Object Storage Service, the AccessKeyId and the AccessKeySecret are required.
func NewService ¶
NewService returns a new Service given a accessKeyId and accessKeySecret.
func (Service) Do ¶
Do sends an HTTP request to OSS and read the HTTP response to v.
The first optional Params is for Header, the second is for Query.
See the method GetResponse and the function ReadBody to get more.
func (Service) GetRequest ¶
func (s Service) GetRequest(method, bucket, object string, body interface{}, args ...Params) (*http.Request, error)
GetRequest returns a new http.Request given a method and optional butcket, object, body.
The first optional Params is for Header, the second is for Query.
A nil body means no body, if the body's type is not []byte, *[]byte, *os.File, *bytes.Buffer, *bytes.Reader and *strings.Reader then encode XML as the body.
The headers Content-Type and Content-Md5 will be set, when encode XML as the body or the body's type is []byte, *[]byte, *bytes.Buffer.
It does not close the *os.File body.
To signature the request call the method Signature.
func (Service) GetResponse ¶
func (s Service) GetResponse(method, bucket, object string, body interface{}, args ...Params) (*http.Response, error)
GetResponse sends an HTTP request to OSS and returns the HTTP response.
The first optional Params is for Header, the second is for Query.
See the method GetRequest to get more.
func (Service) ListBucket ¶
func (s Service) ListBucket(args ...Params) (*ListAllMyBucketsResult, error)
ListBucket returns all the buckets.
The first optional Params is for Header, the second is for Query.
Query predefine parameters: prefix, marker, max-keys.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/service&GetService
func (Service) Signature ¶
Signature url if the seconds > 0 and the Date Header add the seconds as the expires, otherwise signature and set the Authorization header.
If the SecurityToken is not the empty string, then STS be supported.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/access-control&signature-header https://docs.aliyun.com/#/pub/oss/api-reference/access-control&signature-url
type WebsiteConfiguration ¶
type WebsiteConfiguration struct { IndexDocument struct { Suffix string } ErrorDocument struct { Key string } }
WebsiteConfiguration represents the static site configuration.
Relevant documentation:
https://docs.aliyun.com/#/pub/oss/api-reference/bucket&PutBucketWebsite https://docs.aliyun.com/#/pub/oss/api-reference/bucket&GetBucketWebsite
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Aliyun OSS Go SDK Examples - Bucket Operations Aliyun OSS Go SDK Examples - List Bucket Aliyun OSS Go SDK Examples - Multipart Upload File Aliyun OSS Go SDK Examples - Object Operations Aliyun OSS Go SDK Examples - Object Range Get
|
Aliyun OSS Go SDK Examples - Bucket Operations Aliyun OSS Go SDK Examples - List Bucket Aliyun OSS Go SDK Examples - Multipart Upload File Aliyun OSS Go SDK Examples - Object Operations Aliyun OSS Go SDK Examples - Object Range Get |