// download all files in the dir and return list of file names
download all files in the dir and return list of file names
// download all files in the dir and return list of file names
func awsDownloadFilesInDir(sess *session.Session, conf AWS, dirPath string) ([]string, error) {
	svc := s3.New(sess)
	resp, err := svc.ListObjectsV2(&s3.ListObjectsV2Input{Bucket: aws.String(conf.Bucket)})
	if err != nil {
		return nil, err
	}
	dirPath = strings.TrimSuffix(dirPath, "/")
	files := []string{}
	for _, item := range resp.Contents {
		key := *item.Key
		keyDir := filepath.Dir(key)
		keyBase := strings.TrimPrefix(key, keyDir)
		keyBase = strings.TrimPrefix(keyBase, "/")
		if keyDir == dirPath && keyBase != "" {
			files = append(files, keyBase)
		}
	}
	if len(files) == 0 {
		return []string{}, nil
	}
	for _, f := range files {
		_, err := awsDownload(sess, conf, dirPath, f)
		if err != nil {
			return nil, err
		}
	}
	return files, nil
}
func awsDownloadFilesInDir ( sess * session . Session , conf AWS , dirPath string ) ( [ ] string , error ) { svc := s3 . New ( sess ) resp , err := svc . ListObjectsV2 ( & s3 . ListObjectsV2Input { Bucket : aws . String ( conf . Bucket ) } ) if err != nil { return nil , err } dirPath = strings . TrimSuffix ( dirPath , " " ) files := [ ] string { } for _ , item := range resp . Contents { key := * item . Key keyDir := filepath . Dir ( key ) keyBase := strings . TrimPrefix ( key , keyDir ) keyBase = strings . TrimPrefix ( keyBase , " " ) if keyDir == dirPath && keyBase != " " { files = append ( files , keyBase ) } } if len ( files ) == 0 { return [ ] string { } , nil } for _ , f := range files { _ , err := awsDownload ( sess , conf , dirPath , f ) if err != nil { return nil , err } } return files , nil }
download all files in the dir and return list of file names
download all files in the dir and return list of file names
// list all items in bucket // get only those in our folder // download all files in folder