func drops(files []string, typ, dir, from string) error { //to get from rawgit var repo string if typ == "services" { repo = "eris-services" } else if typ == "actions" { repo = "eris-actions" } else if typ == "chains" { repo = "eris-chains" } if !util.DoesDirExist(dir) { if err := os.MkdirAll(dir, 0777); err != nil { return err } } buf := new(bytes.Buffer) if from == "toadserver" { for _, file := range files { url := fmt.Sprintf("%s:11113/getfile/%s", ipfs.SexyUrl(), file) log.WithField(file, url).Debug("Getting file from url") log.WithField(file, dir).Debug("Dropping file to") if err := ipfs.DownloadFromUrlToFile(url, file, dir, buf); err != nil { return err } } } else if from == "rawgit" { for _, file := range files { log.WithField(file, dir).Debug("Getting file from GitHub, dropping into:") if err := util.GetFromGithub("eris-ltd", repo, "master", file, dir, file, buf); err != nil { return err } } } return nil }
func GetFromGithub(org, repo, branch, path, fileName string, w io.Writer) error { url := "https://rawgit.com/" + strings.Join([]string{org, repo, branch, path}, "/") w.Write([]byte("Will download from url -> " + url)) return ipfs.DownloadFromUrlToFile(url, fileName, "", w) }