You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: reader.go
    path of file: ./repos/sealer/vendor/github.com/containers/image/v5/docker/internal/tarfile
    
    the code of the file until where you have to start completion: package tarfile

import (
	"archive/tar"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"os"
	"path"

	"github.com/containers/image/v5/docker/reference"
	"github.com/containers/image/v5/internal/iolimits"
	"github.com/containers/image/v5/internal/tmpdir"
	"github.com/containers/image/v5/pkg/compression"
	"github.com/containers/image/v5/types"
)

// Reader is a ((docker save)-formatted) tar ar
    
func NewReaderFromStream(sys *types.SystemContext, inputStream io.Reader) (*Reader, error) {
	// Save inputStream to a temporary file
	tarCopyFile, err := os.CreateTemp(tmpdir.TemporaryDirectoryForBigFiles(sys), "docker-tar")
	if err != nil {
		return nil, fmt.Errorf("creating temporary file: %w", err)
	}
	defer tarCopyFile.Close()

	succeeded := false
	defer func() {
		if !succeeded {
			os.Remove(tarCopyFile.Name())
		}
	}()

	// In order to be compatible with docker-load, we need to support
	// auto-decompression (it's also a nice quality-of-life thing to avoid
	// giving users really confusing "invalid tar header" errors).
	uncompressedStream, _, err := compression.AutoDecompress(inputStream)
	if err != nil {
		return nil, fmt.Errorf("auto-decompressing input: %w", err)
	}
	defer uncompressedStream.Close()

	// Copy the plain archive to the temporary file.
	//
	// TODO: This can take quite some time, and should ideally be cancellable
	//       using a context.Context.
	if _, err := io.Copy(tarCopyFile, uncompressedStream); err != nil {
		return nil, fmt.Errorf("copying contents to temporary file %q: %w", tarCopyFile.Name(), err)
	}
	succeeded = true

	return newReader(tarCopyFile.Name(), true)
}