ProcessDirectory enqueues all files matching a specific prefix for processing by s3Input. If prefix is actually a s3 url use the bucket there instead of the one provided at creation time. This function makes (multiple) remotes call to acquire the listing of all files matching the specified prefix i
(prefix string)
| 49 | // all files matching the specified prefix in the bucket, and enqueue |
| 50 | // them for processing, |
| 51 | func (s *S3Input) ProcessDirectory(prefix string) error { |
| 52 | s3Scheme, s3Bucket, s3Key, err := s.choosePathComponents(prefix) |
| 53 | if err != nil { |
| 54 | return err |
| 55 | } |
| 56 | isFullPath, err := isValidScheme(s3Scheme) |
| 57 | if err != nil { |
| 58 | return err |
| 59 | } |
| 60 | return s.svc.ListObjectsPages(&s3.ListObjectsInput{ |
| 61 | Bucket: aws.String(s3Bucket), |
| 62 | Prefix: aws.String(s3Key), |
| 63 | }, func(page *s3.ListObjectsOutput, lastPage bool) bool { |
| 64 | for _, o := range page.Contents { |
| 65 | var key string |
| 66 | // If prefix is a full s3 url it means we need to provide |
| 67 | // openS3File with the full path in order to be able to correctly |
| 68 | // fetch the size and the contents of the file. |
| 69 | if isFullPath { |
| 70 | key = fmt.Sprintf("%s://%s/%s", s3Scheme, s3Bucket, *o.Key) |
| 71 | } else { |
| 72 | key = *o.Key |
| 73 | } |
| 74 | s.ProcessFile(key) |
| 75 | } |
| 76 | return true |
| 77 | }) |
| 78 | } |
| 79 | |
| 80 | func (s *S3Input) openS3File(fn string) (io.ReadCloser, int64, time.Time, *url.URL, error) { |
| 81 | _, s3Bucket, s3Key, err := s.choosePathComponents(fn) |
nothing calls this directly
no test coverage detected