1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
11 "git.arvados.org/arvados.git/sdk/go/arvados"
12 "git.arvados.org/arvados.git/sdk/go/manifest"
15 // ErrNoManifest indicates the given collection has no manifest
16 // information (e.g., manifest_text was excluded by a "select"
17 // parameter when retrieving the collection record).
18 var ErrNoManifest = errors.New("Collection has no manifest")
20 // CollectionFileReader returns a Reader that reads content from a single file
21 // in the collection. The filename must be relative to the root of the
22 // collection. A leading prefix of "/" or "./" in the filename is ignored.
23 func (kc *KeepClient) CollectionFileReader(collection map[string]interface{}, filename string) (arvados.File, error) {
24 mText, ok := collection["manifest_text"].(string)
26 return nil, ErrNoManifest
28 fs, err := (&arvados.Collection{ManifestText: mText}).FileSystem(nil, kc)
32 return fs.OpenFile(filename, os.O_RDONLY, 0)
35 func (kc *KeepClient) ManifestFileReader(m manifest.Manifest, filename string) (arvados.File, error) {
36 fs, err := (&arvados.Collection{ManifestText: m.Text}).FileSystem(nil, kc)
40 return fs.OpenFile(filename, os.O_RDONLY, 0)