// copy a file from the bucket to the local machine
copy a file from the bucket to the local machine
// copy a file from the bucket to the local machine
func cmdRawDown(cobraCmd *cobra.Command, args []string) error {
	remote := args[0]
	local := args[1]
	conf, err := loadConfig(configFile)
	if err != nil {
		return err
	}
	sess := awsSession(conf.AWS)
	if strings.HasSuffix(remote, "/") {
		if err := os.Mkdir(local, 0777); err != nil {
			return err
		}
		if err := os.Chdir(local); err != nil {
			return err
		}
		_, err = awsDownloadFilesInDir(sess, conf.AWS, remote)
		return err
	}
	dir := filepath.Dir(remote)
	fileName := filepath.Base(remote)
	file, err := awsDownload(sess, conf.AWS, dir, fileName)
	if err != nil {
		return err
	}
	oldName := file.Name()
	newName := local
	if oldName != newName {
		return os.Rename(oldName, newName)
	}
	return nil
}
func cmdRawDown ( cobraCmd * cobra . Command , args [ ] string ) error { remote := args [ 0 ] local := args [ 1 ] conf , err := loadConfig ( configFile ) if err != nil { return err } sess := awsSession ( conf . AWS ) if strings . HasSuffix ( remote , " " ) { if err := os . Mkdir ( local , 0777 ) ; err != nil { return err } if err := os . Chdir ( local ) ; err != nil { return err } _ , err = awsDownloadFilesInDir ( sess , conf . AWS , remote ) return err } dir := filepath . Dir ( remote ) fileName := filepath . Base ( remote ) file , err := awsDownload ( sess , conf . AWS , dir , fileName ) if err != nil { return err } oldName := file . Name ( ) newName := local if oldName != newName { return os . Rename ( oldName , newName ) } return nil }
copy a file from the bucket to the local machine
copy a file from the bucket to the local machine
// if remote ends in /, fetch the whole directory and return // otherwise, just download the one file // rename if necessary