func Fetch(cmd string, params ...string) { if len(params) == 2 || len(params) == 3 { remoteResUrl := params[0] bucket := params[1] key := "" if len(params) == 3 { key = params[2] } gErr := accountS.Get() if gErr != nil { fmt.Println(gErr) return } mac := digest.Mac{ accountS.AccessKey, []byte(accountS.SecretKey), } fetchResult, err := qshell.Fetch(&mac, remoteResUrl, bucket, key) if err != nil { if v, ok := err.(*rpc.ErrorInfo); ok { fmt.Println("Fetch error,", v.Code, v.Err) } else { fmt.Println("Fetch error,", err.Error()) } } else { fmt.Println("Key:", fetchResult.Key) fmt.Println("Hash:", fetchResult.Hash) } } else { CmdHelp(cmd) } }
func Fetch(cmd string, params ...string) { if len(params) == 2 || len(params) == 3 { remoteResUrl := params[0] bucket := params[1] key := "" if len(params) == 3 { key = params[2] } accountS.Get() mac := digest.Mac{ accountS.AccessKey, []byte(accountS.SecretKey), } fetchResult, err := qshell.Fetch(&mac, remoteResUrl, bucket, key) if err != nil { log.Error("Fetch error,", err) } else { fmt.Println("Key:", fetchResult.Key) fmt.Println("Hash:", fetchResult.Hash) } } else { CmdHelp(cmd) } }