artifact

package
v0.0.0-...-955c50f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 23 Imported by: 19

Documentation

Overview

Package artifact contains utilities for working downloading files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanGetS3Object

func CanGetS3Object(context context.T, amazonS3URL s3util.AmazonS3URL) bool

CanGetS3Object returns true if it is possible to fetch an object because it exists, is not deleted, and read permissions exist for this request

func FileCopy

func FileCopy(log log.T, destinationPath string, src io.Reader) (written int64, err error)

FileCopy copies the content from reader to destinationPath file

func ListS3Directory

func ListS3Directory(context context.T, amazonS3URL s3util.AmazonS3URL) (folderNames []string, err error)

ListS3Directory returns all the objects (files and folders) under a given S3 URL where folders are keys whose prefix is the URL key and contain a / after the prefix.

func ListS3Folders

func ListS3Folders(context context.T, amazonS3URL s3util.AmazonS3URL) (folderNames []string, err error)

ListS3Folders returns the folders under a given S3 URL where folders are keys whose prefix is the URL key and contain a / after the prefix. The folder name is the part between the prefix and the /.

func Md5HashValue

func Md5HashValue(log log.T, filePath string) (hash string, err error)

Md5HashValue gets the md5 hash value

func S3FileRead

func S3FileRead(context context.T, s3FullPath string) (output []byte, err error)

S3FileRead attempts to read a file content from S3 via s3 client.

func Sha256HashValue

func Sha256HashValue(log log.T, filePath string) (hash string, err error)

Sha256HashValue gets the sha256 hash value

func VerifyHash

func VerifyHash(log log.T, input DownloadInput, output DownloadOutput) (bool, error)

VerifyHash verifies the hash of the url file as per specified hash algorithm type and its value

Types

type DownloadInput

type DownloadInput struct {
	SourceURL            string
	DestinationDirectory string
	SourceChecksums      map[string]string
}

DownloadInput specifies the input to file download operation

type DownloadOutput

type DownloadOutput struct {
	LocalFilePath string
	IsUpdated     bool
	IsHashMatched bool
}

DownloadOutput holds the result of file download operation.

func Download

func Download(context context.T, input DownloadInput) (output DownloadOutput, err error)

Download is a generic utility which attempts to download smartly.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL