// Connect - connect to cos
connect to cos
// Connect - connect to cos
func (c *COS) Connect() error {
	u, err := url.Parse(c.Config.RowURL)
	if err != nil {
		return err
	}
	b := &cos.BaseURL{BucketURL: u}
	timeout, err := time.ParseDuration(c.Config.Timeout)
	if err != nil {
		return err
	}
	c.client = cos.NewClient(b, &http.Client{
		Timeout: timeout,
		Transport: &cos.AuthorizationTransport{
			SecretID:  c.Config.SecretID,
			SecretKey: c.Config.SecretKey,
			Transport: &debug.DebugRequestTransport{
				RequestHeader:  c.Debug,
				RequestBody:    false,
				ResponseHeader: c.Debug,
				ResponseBody:   false,
			},
		},
	})
	_, err = c.client.Bucket.Head(context.Background())
	return err
}
func ( c * COS ) Connect ( ) error { u , err := url . Parse ( c . Config . RowURL ) if err != nil { return err } b := & cos . BaseURL { BucketURL : u } timeout , err := time . ParseDuration ( c . Config . Timeout ) if err != nil { return err } c . client = cos . NewClient ( b , & http . Client { Timeout : timeout , Transport : & cos . AuthorizationTransport { SecretID : c . Config . SecretID , SecretKey : c . Config . SecretKey , Transport : & debug . DebugRequestTransport { RequestHeader : c . Debug , RequestBody : false , ResponseHeader : c . Debug , ResponseBody : false , } , } , } ) _ , err = c . client . Bucket . Head ( context . Background ( ) ) return err }
connect to cos
connect to cos
// request debug // check bucket exists