예제 #1
0
func exportFile(fileName, gateway string) (string, error) {
	var hash string
	var err error

	if logger.Level > 0 {
		hash, err = ipfs.SendToIPFS(fileName, gateway, logger.Writer)
	} else {
		hash, err = ipfs.SendToIPFS(fileName, gateway, bytes.NewBuffer([]byte{}))
	}
	if err != nil {
		return "", err
	}

	return hash, nil
}
예제 #2
0
파일: handle.go 프로젝트: mxjxn/eris-cli
func exportFile(fileName, gateway string) (string, error) {
	var hash string
	var err error

	if log.GetLevel() > 0 {
		hash, err = ipfs.SendToIPFS(fileName, gateway, os.Stdout)
	} else {
		hash, err = ipfs.SendToIPFS(fileName, gateway, bytes.NewBuffer([]byte{}))
	}
	if err != nil {
		return "", err
	}

	return hash, nil
}
예제 #3
0
func exportFile(servName string) (string, error) {
	fileName := FindServiceDefinitionFile(servName)

	var hash string
	var err error
	if logger.Level > 0 {
		hash, err = ipfs.SendToIPFS(fileName, "", logger.Writer)
	} else {
		hash, err = ipfs.SendToIPFS(fileName, "", bytes.NewBuffer([]byte{}))
	}

	if err != nil {
		return "", err
	}

	return hash, nil
}
예제 #4
0
파일: manage.go 프로젝트: mxjxn/eris-cli
func exportFile(chainName string) (string, error) {
	fileName := util.GetFileByNameAndType("chains", chainName)

	var hash string
	var err error
	if log.GetLevel() > 0 {
		hash, err = ipfs.SendToIPFS(fileName, "", os.Stdout)
	} else {
		hash, err = ipfs.SendToIPFS(fileName, "", bytes.NewBuffer([]byte{}))
	}

	if err != nil {
		return "", err
	}

	return hash, nil
}
예제 #5
0
func exportFile(servName string) (string, error) {
	fileName := fmt.Sprintf("%s%s", FindServiceDefinitionFile(servName), ".toml")

	fn := path.Join(ServicesPath, fileName)

	var hash string
	var err error

	if logger.Level > 0 {
		hash, err = ipfs.SendToIPFS(fn, "", logger.Writer)
	} else {
		hash, err = ipfs.SendToIPFS(fn, "", bytes.NewBuffer([]byte{}))
	}

	if err != nil {
		return "", err
	}

	return hash, nil
}
예제 #6
0
func exportFile(actionName string) (string, error) {
	var err error
	fileName := util.GetFileByNameAndType("actions", actionName)
	if fileName == "" {
		return "", fmt.Errorf("no file to export")
	}

	var hash string
	if logger.Level > 0 {
		hash, err = ipfs.SendToIPFS(fileName, "", logger.Writer)
	} else {
		hash, err = ipfs.SendToIPFS(fileName, "", bytes.NewBuffer([]byte{}))
	}

	if err != nil {
		return "", err
	}

	return hash, nil
}
예제 #7
0
func exportDir(dirName, gateway string) (string, error) {
	var hashes string
	var err error

	files, err := ioutil.ReadDir(dirName)
	if err != nil {
		return "", fmt.Errorf("error reading directory %v\n", err)
	}
	gwd, err := os.Getwd()
	if err != nil {
		return "", fmt.Errorf("error getting working directory %v\n", err)
	}
	hashArray := make([]string, len(files))
	fileNames := make([]string, len(files))
	//the dir ends up in the loop & tries to post
	for i := range files {
		//hacky
		file := path.Join(gwd, dirName, files[i].Name())
		if logger.Level > 0 {
			hashArray[i], err = ipfs.SendToIPFS(file, gateway, logger.Writer)
		} else {
			hashArray[i], err = ipfs.SendToIPFS(file, gateway, bytes.NewBuffer([]byte{}))
		}
		if err != nil {
			return "", fmt.Errorf("error reading file %v\n", err)
		}
		fileNames[i] = files[i].Name()
	}

	err = writeCsv(hashArray, fileNames)
	if err != nil {
		return "", err
	}

	hashes = strings.Join(hashArray, "\n")

	return hashes, nil
}