MCPcopy Create free account
hub / github.com/google/go-cloud / ExampleBucket_NewReader

Function ExampleBucket_NewReader

blob/example_test.go:35–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33)
34
35func ExampleBucket_NewReader() {
36 // PRAGMA: This example is used on gocloud.dev; PRAGMA comments adjust how it is shown and can be ignored.
37 // PRAGMA: On gocloud.dev, hide lines until the next blank line.
38 ctx := context.Background()
39 var bucket *blob.Bucket
40
41 // Open the key "foo.txt" for reading with the default options.
42 r, err := bucket.NewReader(ctx, "foo.txt", nil)
43 if err != nil {
44 log.Fatal(err)
45 }
46 defer r.Close()
47 // Readers also have a limited view of the blob's metadata.
48 fmt.Println("Content-Type:", r.ContentType())
49 fmt.Println()
50 // Copy from the reader to stdout.
51 if _, err := io.Copy(os.Stdout, r); err != nil {
52 log.Fatal(err)
53 }
54}
55
56func ExampleBucket_NewRangeReader() {
57 // PRAGMA: This example is used on gocloud.dev; PRAGMA comments adjust how it is shown and can be ignored.

Callers

nothing calls this directly

Calls 4

NewReaderMethod · 0.95
CloseMethod · 0.95
ContentTypeMethod · 0.95
CopyMethod · 0.65

Tested by

no test coverage detected