func NewTaskPushInfo(file string) (*TaskPushInfo, error) { info := new(TaskPushInfo) err := util.ReadJsonFile(file, info) if err != nil { return nil, err } return info, err }
func NewNanduInfo(file string) (*NanduInfo, error) { info := new(NanduInfo) err := util.ReadJsonFile(file, info) if err != nil { return nil, err } return info, err }
func NewDownloadInfo(file string) (*DownloadInfo, error) { info := new(DownloadInfo) err := util.ReadJsonFile(file, info) if err != nil { return nil, err } if info.AppKey == "" || info.AppSecret == "" || info.BucketName == "" || info.EndPoint == "" || info.EncryptKey == "" { return nil, errors.New("missing required download information") } client, err := oss.New(info.EndPoint, info.AppKey, info.AppSecret) if err != nil { return nil, errors.New("can't connect to aliyun oss") } bucket, err := client.Bucket(info.BucketName) if err != nil { return nil, errors.New("can't get specified bucket") } info.Bucket = bucket return info, err }