Skip to content

Commit

Permalink
Modify the document address and error comments (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzong18 authored and huiguangjun committed Mar 23, 2023
1 parent 8e7b954 commit 2273dd7
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 51 deletions.
14 changes: 7 additions & 7 deletions oss/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Bucket struct {
// 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
// https://www.alibabacloud.com/help/en/object-storage-service/latest/putobject
//
// error it's nil if no error, otherwise it's an error object.
//
Expand Down Expand Up @@ -119,7 +119,7 @@ func (bucket Bucket) DoPutObject(request *PutObjectRequest, options []Option) (*
// 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
// https://www.alibabacloud.com/help/en/object-storage-service/latest/getobject
//
// 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.
Expand Down Expand Up @@ -228,7 +228,7 @@ func (bucket Bucket) DoGetObject(request *GetObjectRequest, options []Option) (*
// 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
// https://www.alibabacloud.com/help/en/object-storage-service/latest/copyobject
//
// error it's nil if no error, otherwise it's an error object.
//
Expand Down Expand Up @@ -595,8 +595,8 @@ func (bucket Bucket) ListObjects(options ...Option) (ListObjectsResult, error) {
return out, err
}

// ListObjectsV2 lists the objects under the current bucket.
// Recommend to use ListObjectsV2 to replace ListObjects
// ListOListObjectsV2bjects lists the objects under the current bucket.
// ListObjectsResultV2 the return value after operation succeeds (only valid when error is nil).
func (bucket Bucket) ListObjectsV2(options ...Option) (ListObjectsResultV2, error) {
var out ListObjectsResultV2
Expand Down Expand Up @@ -667,7 +667,7 @@ func (bucket Bucket) SetObjectMeta(objectKey string, options ...Option) error {
//
// 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
// IfMatch, IfNoneMatch. For more details check out https://www.alibabacloud.com/help/en/object-storage-service/latest/headobject
//
// http.Header object meta when error is nil.
// error it's nil if no error, otherwise it's an error object.
Expand Down Expand Up @@ -921,7 +921,7 @@ func (bucket Bucket) SignURL(objectKey string, method HTTPMethod, expiredInSec i
// 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
// https://www.alibabacloud.com/help/en/object-storage-service/latest/putobject
//
// error it's nil if no error, otherwise it's an error object.
//
Expand Down Expand Up @@ -995,7 +995,7 @@ func (bucket Bucket) DoPutObjectWithURL(signedURL string, reader io.Reader, opti
// 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
// https://www.alibabacloud.com/help/en/object-storage-service/latest/getobject
//
// 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.
Expand Down
46 changes: 22 additions & 24 deletions oss/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func (client Client) DeleteBucket(bucketName string, options ...Option) 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
// https://www.alibabacloud.com/help/en/object-storage-service/latest/getbucketlocation
//
// bucketName the bucket name
//
Expand Down Expand Up @@ -348,7 +348,7 @@ func (client Client) GetBucketACL(bucketName string, options ...Option) (GetBuck
// 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
// https://www.alibabacloud.com/help/en/object-storage-service/latest/putbucketlifecycle
//
// 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.
Expand Down Expand Up @@ -466,26 +466,26 @@ func (client Client) GetBucketLifecycleXml(bucketName string, options ...Option)
// 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.
// the allowing empty referrer flag. Note that this applies to requests from web browser 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
// https://www.alibabacloud.com/help/en/object-storage-service/latest/putbucketreferer
//
// 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.
// referrers 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 Client) SetBucketReferer(bucketName string, referers []string, allowEmptyReferer bool, options ...Option) error {
func (client Client) SetBucketReferer(bucketName string, referrers []string, allowEmptyReferer bool, options ...Option) error {
rxml := RefererXML{}
rxml.AllowEmptyReferer = allowEmptyReferer
if referers == nil {
if referrers == nil {
rxml.RefererList = append(rxml.RefererList, "")
} else {
for _, referer := range referers {
rxml.RefererList = append(rxml.RefererList, referer)
for _, referrer := range referrers {
rxml.RefererList = append(rxml.RefererList, referrer)
}
}

Expand Down Expand Up @@ -535,7 +535,7 @@ func (client Client) GetBucketReferer(bucketName string, options ...Option) (Get
//
// 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
// For more information, please check out https://www.alibabacloud.com/help/en/object-storage-service/latest/putbucketlogging
//
// bucketName bucket name to enable the log.
// targetBucket the target bucket name to store the log files.
Expand Down Expand Up @@ -619,7 +619,7 @@ func (client Client) GetBucketLogging(bucketName string, options ...Option) (Get
// 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
// For more information, please check out: https://www.alibabacloud.com/help/en/object-storage-service/latest/putbucketwebsite
//
// bucketName the bucket name to enable static web site.
// indexDocument index page.
Expand Down Expand Up @@ -656,7 +656,7 @@ func (client Client) SetBucketWebsite(bucketName, indexDocument, errorDocument s
// SetBucketWebsiteDetail sets the bucket's static website's detail
//
// 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
// For more information, please check out: https://www.alibabacloud.com/help/en/object-storage-service/latest/putbucketwebsite
//
// bucketName the bucket name to enable static web site.
//
Expand Down Expand Up @@ -689,7 +689,7 @@ func (client Client) SetBucketWebsiteDetail(bucketName string, wxml WebsiteXML,
// SetBucketWebsiteXml sets the bucket's static website's rule
//
// 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
// For more information, please check out: https://www.alibabacloud.com/help/en/object-storage-service/latest/putbucketwebsite
//
// bucketName the bucket name to enable static web site.
//
Expand Down Expand Up @@ -777,8 +777,7 @@ func (client Client) GetMetaQueryStatus(bucketName string, options ...Option) (G
// metaQuery the option of query
//
// DoMetaQueryResult 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.
// error it's nil if no error, otherwise it's an error object.
//
func (client Client) DoMetaQuery(bucketName string, metaQuery MetaQuery, options ...Option) (DoMetaQueryResult, error) {
var out DoMetaQueryResult
Expand All @@ -790,14 +789,13 @@ func (client Client) DoMetaQuery(bucketName string, metaQuery MetaQuery, options
return out, err
}

// DoMetaQuery Queries the objects that meet specified conditions and lists the information about objects based on specified fields and sorting methods.
// DoMetaQueryXml Queries the objects that meet specified conditions and lists the information about objects based on specified fields and sorting methods.
//
// bucketName the bucket name
//
// metaQuery the option of query
//
// DoMetaQueryResult 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 Client) DoMetaQueryXml(bucketName string, metaQueryXml string, options ...Option) (DoMetaQueryResult, error) {
Expand Down Expand Up @@ -2069,7 +2067,7 @@ func (client Client) GetBucketAccessMonitor(bucketName string, options ...Option
return out, err
}

// GetBucketAccessMonitor get bucket's access monitor config
// GetBucketAccessMonitorXml get bucket's access monitor config
// bucketName the bucket name.
// string the access monitor configuration result of bucket xml foramt.
// error it's nil if no error, otherwise it's an error object.
Expand Down Expand Up @@ -2099,7 +2097,7 @@ func (client Client) PutBucketAccessMonitor(bucketName string, accessMonitor Put
return err
}

// PutBucketAccessMonitor get bucket's access monitor config
// PutBucketAccessMonitorXml get bucket's access monitor config
// bucketName the bucket name.
// xmlData the access monitor configuration in xml foramt
// error it's nil if no error, otherwise it's an error object.
Expand Down Expand Up @@ -2208,7 +2206,7 @@ func (client Client) GetBucketCnameToken(bucketName string, cname string, option
return out, err
}

// PutBucketCname map a custom domain name to a bucket
// PutBucketCnameXml map a custom domain name to a bucket
// bucketName the bucket name.
// xmlBody the cname configuration in xml foramt
// error it's nil if no error, otherwise it's an error object.
Expand Down Expand Up @@ -2629,14 +2627,14 @@ func SetLogger(Logger *log.Logger) ClientOption {
}
}

// SetCredentialsProvider sets funciton for get the user's ak
// SetCredentialsProvider sets function for get the user's ak
func SetCredentialsProvider(provider CredentialsProvider) ClientOption {
return func(client *Client) {
client.Config.CredentialsProvider = provider
}
}

// SetLocalAddr sets funciton for local addr
// SetLocalAddr sets function for local addr
func SetLocalAddr(localAddr net.Addr) ClientOption {
return func(client *Client) {
client.Config.LocalAddr = localAddr
Expand All @@ -2657,14 +2655,14 @@ func AdditionalHeaders(headers []string) ClientOption {
}
}

// only effective from go1.7 onward,RedirectEnabled set http redirect enabled or not
// RedirectEnabled only effective from go1.7 onward,RedirectEnabled set http redirect enabled or not
func RedirectEnabled(enabled bool) ClientOption {
return func(client *Client) {
client.Config.RedirectEnabled = enabled
}
}

// skip verifying tls certificate file
// InsecureSkipVerify skip verifying tls certificate file
func InsecureSkipVerify(enabled bool) ClientOption {
return func(client *Client) {
client.Config.InsecureSkipVerify = enabled
Expand Down
12 changes: 6 additions & 6 deletions oss/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,7 @@ func (s *OssClientSuite) TestBucketLifecycleNegative(c *C) {
// TestSetBucketReferer
func (s *OssClientSuite) TestSetBucketReferer(c *C) {
var bucketNameTest = bucketNamePrefix + RandLowStr(6)
var referers = []string{"http://www.aliyun.com", "https://www.aliyun.com"}
var referrers = []string{"http://www.aliyun.com", "https://www.aliyun.com"}

client, err := New(endpoint, accessID, accessKey)
c.Assert(err, IsNil)
Expand All @@ -1393,7 +1393,7 @@ func (s *OssClientSuite) TestSetBucketReferer(c *C) {
c.Assert(len(res.RefererList), Equals, 0)

// Set referers
err = client.SetBucketReferer(bucketNameTest, referers, false)
err = client.SetBucketReferer(bucketNameTest, referrers, false)
c.Assert(err, IsNil)
time.Sleep(timeoutInOperation)

Expand All @@ -1404,12 +1404,12 @@ func (s *OssClientSuite) TestSetBucketReferer(c *C) {
c.Assert(res.RefererList[1], Equals, "https://www.aliyun.com")

// Reset referer, referers empty
referers = []string{""}
err = client.SetBucketReferer(bucketNameTest, referers, true)
referrers = []string{""}
err = client.SetBucketReferer(bucketNameTest, referrers, true)
c.Assert(err, IsNil)

referers = []string{}
err = client.SetBucketReferer(bucketNameTest, referers, true)
referrers = []string{}
err = client.SetBucketReferer(bucketNameTest, referrers, true)
c.Assert(err, IsNil)

res, err = client.GetBucketReferer(bucketNameTest)
Expand Down
4 changes: 2 additions & 2 deletions oss/multipart.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
// 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
// https://www.alibabacloud.com/help/en/object-storage-service/latest/initiatemultipartupload
//
// 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.
Expand Down Expand Up @@ -145,7 +145,7 @@ func (bucket Bucket) DoUploadPart(request *UploadPartRequest, options []Option)
// 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
// https://www.alibabacloud.com/help/en/object-storage-service/latest/uploadpartcopy
//
// UploadPart the return value consists of PartNumber and ETag.
// error it's nil if the operation succeeds, otherwise it's an error object.
Expand Down

0 comments on commit 2273dd7

Please sign in to comment.