Documentation ¶
Overview ¶
The gcs package implements a resource for Google Storage. A client will be create lazily on first usage.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( GzipContentType = "application/gzip" XZipContentType = "application/x-zip-compressed" ZipContentType = "application/zip" OctetStreamContentType = "application/octet-stream" BinaryOctetStreamContentType = "binary/octet-stream" TextPlainContentType = "text/plain" XmlContentType = "text/xml" XshContentType = "text/x-sh" CsvContentType = "text/csv" )
Functions ¶
This section is empty.
Types ¶
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
Resource is a resource in google storage. To detect a change, we will poll on an interval and compare the version from the gcs metadata by using the Metageneration number and Generation number.
When providing an UpdateFunc for these updates, you should consider the content type. Some typical content types have been defined in this package.
func NewResource ¶ added in v0.0.2
func (Resource) Poll ¶
Poll lazily initializes a storage client and then uses it to pull the attributes using the bucket and blob. The *ObjectAttrs which is returns contains metadata for the storage blob. We pull the ContentType, Metageneration, and Generation and store them locally to compare with the remote object. The ContentType should be referenced when deciding how to use the reader provided.
See: https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#ObjectAttrs
func (Resource) Refresh ¶
func (r Resource) Refresh(ctx context.Context, updateFunc func(io.Reader), errorHandler func(error))
Refresh currently does not distinguish between a file or a folder level object in GCS. It provides a reader for getting the data from the GCS object. It also manages the closing of the reader after completion.