func New(zone int, cfg *Config) (p *Client) { p = new(Client) if cfg != nil { p.Config = *cfg } p.mac = qbox.NewMac(p.AccessKey, p.SecretKey) p.Client = rpc.Client{qbox.NewClient(p.mac, p.Transport)} if p.RSHost == "" { p.RSHost = defaultRsHost } if p.RSFHost == "" { p.RSFHost = defaultRsfHost } if p.Scheme != "https" { p.Scheme = "http" } if p.APIHost == "" { p.APIHost = api.DefaultApiHost } p.apiCli = api.NewClient(p.APIHost, p.Scheme) if zone < 0 || zone >= len(zones) { return } if len(p.UpHosts) == 0 { p.UpHosts = zones[zone].UpHosts } if p.IoHost == "" { p.IoHost = zones[zone].IoHost } return }
func NewUploader(zone int, cfg *UploadConfig) (p Uploader) { var uc UploadConfig if cfg != nil { uc = *cfg } if uc.Scheme != "https" { uc.Scheme = "http" } if uc.APIHost == "" { uc.APIHost = api.DefaultApiHost } if len(uc.UpHosts) == 0 { if zone > 0 && zone < len(zones) { uc.UpHosts = zones[zone].UpHosts } } p.UpHosts = uc.UpHosts p.Conn.Client = &http.Client{Transport: uc.Transport} p.ApiCli = api.NewClient(uc.APIHost, uc.Scheme) return }