Open opens a file for streaming
(ctx context.Context, options ...fs.OpenOption)
| 843 | |
| 844 | // Open opens a file for streaming |
| 845 | func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (io.ReadCloser, error) { |
| 846 | fs.FixRangeOption(options, o.size) |
| 847 | rangeValue := "" |
| 848 | for _, option := range options { |
| 849 | switch option.(type) { |
| 850 | case *fs.RangeOption, *fs.SeekOption: |
| 851 | _, rangeValue = option.Header() |
| 852 | } |
| 853 | } |
| 854 | |
| 855 | if o.size == 0 { |
| 856 | return io.NopCloser(bytes.NewReader(nil)), nil |
| 857 | } |
| 858 | |
| 859 | var stream io.ReadCloser |
| 860 | err := o.f.pacer.Call(func() (bool, error) { |
| 861 | var err error |
| 862 | stream, err = buckets.DownloadFileStream(ctx, o.f.cfg, o.id, rangeValue) |
| 863 | return o.f.shouldRetry(ctx, err) |
| 864 | }) |
| 865 | if err != nil { |
| 866 | return nil, err |
| 867 | } |
| 868 | return stream, nil |
| 869 | } |
| 870 | |
| 871 | // Update updates an existing file or creates a new one |
| 872 | func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) error { |
nothing calls this directly
no test coverage detected