ListObjects returns objects list after evaluating the passed options. api := client.New(....) for object := range api.ListObjects(ctx, "mytestbucket", minio.ListObjectsOptions{Prefix: "starthere", Recursive:true}) { fmt.Println(object) } If caller cancels the context, then the last entry o
(ctx context.Context, bucketName string, opts ListObjectsOptions)
| 762 | // caller must drain the channel entirely and wait until channel is closed before proceeding, without |
| 763 | // waiting on the channel to be closed completely you might leak goroutines. |
| 764 | func (c *Client) ListObjects(ctx context.Context, bucketName string, opts ListObjectsOptions) <-chan ObjectInfo { |
| 765 | objectStatCh := make(chan ObjectInfo, 1) |
| 766 | go func() { |
| 767 | defer close(objectStatCh) |
| 768 | if contextCanceled(ctx) { |
| 769 | objectStatCh <- ObjectInfo{Err: ctx.Err()} |
| 770 | return |
| 771 | } |
| 772 | |
| 773 | var objIter iter.Seq[ObjectInfo] |
| 774 | switch { |
| 775 | case opts.WithVersions: |
| 776 | objIter = c.listObjectVersions(ctx, bucketName, opts) |
| 777 | case opts.UseV1: |
| 778 | objIter = c.listObjects(ctx, bucketName, opts) |
| 779 | default: |
| 780 | location, _ := c.bucketLocCache.Get(bucketName) |
| 781 | if location == "snowball" { |
| 782 | objIter = c.listObjects(ctx, bucketName, opts) |
| 783 | } else { |
| 784 | objIter = c.listObjectsV2(ctx, bucketName, opts) |
| 785 | } |
| 786 | } |
| 787 | for obj := range objIter { |
| 788 | select { |
| 789 | case <-ctx.Done(): |
| 790 | objectStatCh <- ObjectInfo{Err: ctx.Err()} |
| 791 | return |
| 792 | case objectStatCh <- obj: |
| 793 | } |
| 794 | } |
| 795 | }() |
| 796 | return objectStatCh |
| 797 | } |
| 798 | |
| 799 | // ListObjectsIter returns object list as a iterator sequence. |
| 800 | // caller must cancel the context if they are not interested in |
no test coverage detected