Documentation
¶
Overview ¶
Package gs provides a thin wrapper around the Google Cloud Storage client that mirrors the surface of the internal/azblob and internal/s3 packages, so that bbb can treat Google Cloud Storage as a first-class backend addressed via gs://bucket/object paths.
Index ¶
- Constants
- func CopyServerSide(ctx context.Context, src, dst GSPath, _ int, sizeHint int64, ...) error
- func Delete(ctx context.Context, gp GSPath) error
- func DeletePrefix(ctx context.Context, gp GSPath) error
- func DownloadFile(ctx context.Context, gp GSPath, file *os.File, concurrency int, ...) (int64, error)
- func DownloadStream(ctx context.Context, gp GSPath) (io.ReadCloser, error)
- func Endpoint() string
- func HeadObject(ctx context.Context, gp GSPath) (int64, error)
- func ListRecursiveStream(ctx context.Context, gp GSPath, cb func(ObjectMeta) error) error
- func ListStream(ctx context.Context, gp GSPath, cb func(ObjectMeta) error) error
- func MkBucket(ctx context.Context, bucket string) error
- func Project() string
- func SetHTTPClient(c *http.Client)
- func Touch(ctx context.Context, gp GSPath) error
- func UploadFile(ctx context.Context, gp GSPath, file *os.File, _ int, onProgress func(int64)) error
- func UploadStream(ctx context.Context, gp GSPath, reader io.Reader, _ int) error
- type GSPath
- type ObjectMeta
Constants ¶
const (
// Scheme is the path prefix that identifies Google Cloud Storage paths.
Scheme = "gs://"
)
Variables ¶
This section is empty.
Functions ¶
func CopyServerSide ¶
func CopyServerSide(ctx context.Context, src, dst GSPath, _ int, sizeHint int64, onProgress func(copied, total int64)) error
CopyServerSide performs a server-side copy from src to dst within GCS using the rewrite API, which handles objects of any size. sizeHint, when > 0, avoids an attribute lookup. onProgress, when non-nil, receives (copied, total) updates.
func DeletePrefix ¶
DeletePrefix deletes every object under the path's prefix.
func DownloadFile ¶
func DownloadFile(ctx context.Context, gp GSPath, file *os.File, concurrency int, onProgress func(int64)) (int64, error)
DownloadFile downloads the object into file using parallel ranged reads (a single full read for gzip-encoded objects), returning the bytes written.
func DownloadStream ¶
DownloadStream opens the object for streaming reads.
func Endpoint ¶
func Endpoint() string
Endpoint returns the configured custom GCS endpoint (BBB_GS_ENDPOINT or STORAGE_EMULATOR_HOST), or an empty string when targeting Google Cloud.
func HeadObject ¶
HeadObject returns the size of the object, or an error if it does not exist.
func ListRecursiveStream ¶
ListRecursiveStream lists every object under the path (no delimiter), invoking cb with the object name relative to the path prefix.
func ListStream ¶
ListStream lists the immediate children (objects and virtual directories) under the path, invoking cb for each. Directories are reported with a trailing '/'.
func MkBucket ¶
MkBucket creates a bucket. Conflicts are preserved because read access to an existing bucket does not establish ownership in the requested project.
func Project ¶
func Project() string
Project returns the Google Cloud project used for operations that require one (currently bucket creation).
func SetHTTPClient ¶
SetHTTPClient installs a shared *http.Client used when talking to a custom endpoint (emulator). Against real Google Cloud Storage the SDK builds its own authenticated client on top of http.DefaultTransport, which bbb already replaces with the DNS-pinning/logging transport, so the override is only needed for unauthenticated endpoints. Passing nil clears the override. It must be called before the client is first constructed.
func UploadFile ¶
UploadFile uploads a local file to the object, reporting cumulative bytes via onProgress.
Types ¶
type GSPath ¶
type GSPath struct {
Bucket string
Object string // may be empty or end with '/' for a virtual directory
}
GSPath represents a gs:// path (bucket/object).
func (GSPath) IsDirLike ¶
IsDirLike reports whether the path refers to a bucket root or a virtual directory (empty object name or one ending in '/').