// qsConnection makes a connection to qingstor
qsConnection makes a connection to qingstor
// qsConnection makes a connection to qingstor
func qsServiceConnection(opt *Options) (*qs.Service, error) {
	accessKeyID := opt.AccessKeyID
	secretAccessKey := opt.SecretAccessKey
	switch {
	case opt.EnvAuth:
	case accessKeyID == "" && secretAccessKey == "":
	case accessKeyID == "":
		return nil, errors.New("access_key_id not found")
	case secretAccessKey == "":
		return nil, errors.New("secret_access_key not found")
	}
	protocol := "https"
	host := "qingstor.com"
	port := 443
	endpoint := opt.Endpoint
	if endpoint != "" {
		_protocol, _host, _port, err := qsParseEndpoint(endpoint)
		if err != nil {
			return nil, fmt.Errorf("The endpoint \"%s\" format error", endpoint)
		}
		if _protocol != "" {
			protocol = _protocol
		}
		host = _host
		if _port != "" {
			port, _ = strconv.Atoi(_port)
		} else if protocol == "http" {
			port = 80
		}
	}
	cf, err := qsConfig.NewDefault()
	if err != nil {
		return nil, err
	}
	cf.AccessKeyID = accessKeyID
	cf.SecretAccessKey = secretAccessKey
	cf.Protocol = protocol
	cf.Host = host
	cf.Port = port
	cf.ConnectionRetries = opt.ConnectionRetries
	cf.Connection = fshttp.NewClient(fs.Config)
	return qs.Init(cf)
}
func qsServiceConnection ( opt * Options ) ( * qs . Service , error ) { accessKeyID := opt . AccessKeyID secretAccessKey := opt . SecretAccessKey switch { case opt . EnvAuth : case accessKeyID == " " && secretAccessKey == " " : case accessKeyID == " " : return nil , errors . New ( " " ) case secretAccessKey == " " : return nil , errors . New ( " " ) } protocol := " " host := " " port := 443 endpoint := opt . Endpoint if endpoint != " " { _protocol , _host , _port , err := qsParseEndpoint ( endpoint ) if err != nil { return nil , fmt . Errorf ( " \" \" " , endpoint ) } if _protocol != " " { protocol = _protocol } host = _host if _port != " " { port , _ = strconv . Atoi ( _port ) } else if protocol == " " { port = 80 } } cf , err := qsConfig . NewDefault ( ) if err != nil { return nil , err } cf . AccessKeyID = accessKeyID cf . SecretAccessKey = secretAccessKey cf . Protocol = protocol cf . Host = host cf . Port = port cf . ConnectionRetries = opt . ConnectionRetries cf . Connection = fshttp . NewClient ( fs . Config ) return qs . Init ( cf ) }
qsConnection makes a connection to qingstor
qsConnection makes a connection to qingstor
// No need for empty checks if "env_auth" is true // if no access key/secret and iam is explicitly disabled then fall back to anon interaction