# `stream` [](https://godoc.org/github.com/google/go-containerregistry/pkg/v1/stream) The `stream` package contains an implementation of [`v1.Layer`](https://godoc.org/github.com/google/go-containerregistry/pkg/v1#Layer) that supports _streaming_ access, i.e. the layer contents are read once and not buffered. ## Usage ```go package main import ( "os" "github.com/google/go-containerregistry/pkg/name" "github.com/google/go-containerregistry/pkg/v1/remote" "github.com/google/go-containerregistry/pkg/v1/stream" ) // upload the contents of stdin as a layer to a local registry func main() { repo, err := name.NewRepository("localhost:5000/stream") if err != nil { panic(err) } layer := stream.NewLayer(os.Stdin) if err := remote.WriteLayer(repo, layer); err != nil { panic(err) } } ``` ## Structure This implements the layer portion of an [image upload](/pkg/v1/remote#anatomy-of-an-image-upload). We launch a goroutine that is responsible for hashing the uncompressed contents to compute the `DiffID`, gzipping them to produce the `Compressed` contents, and hashing/counting the bytes to produce the `Digest`/`Size`. This goroutine writes to an `io.PipeWriter`, which blocks until `Compressed` reads the gzipped contents from the corresponding `io.PipeReader`.