helpers

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TempFileStrLine = "This is a test file"
	TmpDirectory    = "/tmp"
)

Variables

This section is empty.

Functions

func CreateLocalTempFile

func CreateLocalTempFile(contentSize int, gzipCompress bool) (string, error)

Creates a temporary file (name-collision-safe) in /tmp with given content size in bytes. If gzipCompress is true, output file is a gzip-compressed file. contentSize is the size of the uncompressed content. In case gzipCompress is true, the actual output file size will be different from contentSize (typically gzip-compressed file size < contentSize). Caller is responsible for deleting the created file when done using it. Failure cases: 1. contentSize <= 0 2. os.CreateTemp() returned error or nil handle 3. gzip.NewWriter() returned nil handle 4. Failed to write the content to the created temp file

func DownloadGzipGcsObjectAsCompressed

func DownloadGzipGcsObjectAsCompressed(bucketName, objPathInBucket string) (string, error)

Downloads given gzipped GCS object (with path without 'gs://') to local disk. Fails if the object doesn't exist or permission to read object is not available. Uses go storage client library to download object. Use of gsutil/gcloud is not possible as they both always read back objects with content-encoding: gzip as uncompressed/decompressed irrespective of any argument passed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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