Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
Downloader validates a resource blob.
func NewDownloader ¶
func NewDownloader(logger logger.Logger, fileSystem FileSystem) *Downloader
NewDownloader returns a new resource blob validator.
func (*Downloader) Download ¶
func (v *Downloader) Download( ctx context.Context, reader io.ReadCloser, expectedSHA384 string, expectedSize int64, ) (_ io.ReadCloser, err error)
Download takes a request body ReadCloser containing a resource blob and checks that the size and hash match the expected values. It downloads the blob to a temporary file and returns a ReadCloser that deletes the temporary file on closure.
type FileSystem ¶
type FileSystem interface { // CreateTemp creates a new temporary file in the directory dir, // opens the file for reading and writing, and returns the resulting file. CreateTemp(dir, pattern string) (*os.File, error) // Open opens the named file for reading. Open(name string) (*os.File, error) // Remove removes the named file or (empty) directory. Remove(name string) error }
FileSystem defines a file system for modifying files on a users system.
func DefaultFileSystem ¶
func DefaultFileSystem() FileSystem
DefaultFileSystem returns the default file system.
Click to show internal directories.
Click to hide internal directories.