upload

package
v0.0.0-...-c456180 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2025 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const GzipContentEncoding = "gzip"
View Source
const Timeout = 50

Variables

This section is empty.

Functions

func GetKnownHeaders

func GetKnownHeaders() map[string]bool

Types

type UploadInput

type UploadInput struct {
	FilePath   string
	ObjectName string
}

func ProcessPath

func ProcessPath(path, prefix, glob string, useIgnoreList, includeParent bool) ([]UploadInput, error)

ProcessPath will convert an input path (file or folder) into a list of UploadInput. Each UploadInput object represents a single file that will need to be uploaded to GCS. The prefix parameter will be the prefix for every GCS ObjectName The glob parameter can be used alongside a folder path to do selective filtering. The useIgnoreList parameter can be used to process a .gcloudignore file for additional filtering. The includeParent parameter can be used to maintain or ignore the folder structure in the objects uploaded to GCS.

type UploadResults

type UploadResults struct {
	FilePath   string `json:"file_path"`
	ObjectName string `json:"object_name"`
	Success    bool   `json:"success"`
	Message    string `json:"message,omitempty"`
}

type Uploader

type Uploader struct {
	Gzip        bool
	Concurrency int
	ACL         string
	Headers     map[string]string
}

func (Uploader) UploadObjects

func (u Uploader) UploadObjects(inputs []UploadInput, bucket stiface.BucketHandle) []UploadResults

UploadObjects will upload each UploadInput into the provided bucket. It will perform the uploads concurrently up to the Uploader.Concurrency limit. Results are accumulated into a UploadResults array and returned when everything completes. It's possible that individual uploads can have an error, and the caller can check UploadResults.Success and UploadResults.Message for status and any error message

Jump to

Keyboard shortcuts

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