GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - git-pkgs/gcs: Lightweight Google Cloud Storage client for Go

BranchesTags
Open more actions menu

Latest commit

 

History

18 Commits
18 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
gcs.go
gcs.go
 
 
gcs_test.go
gcs_test.go
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 

Repository files navigation

gcs

gcs implements Google Cloud Storage object operations through the JSON API. Its direct runtime dependencies are cloud.google.com/go/compute/metadata and golang.org/x/oauth2.

Install

go get github.com/git-pkgs/gcs

Write and read objects

ctx := context.Background()
bucket, err := gcs.OpenBucket(ctx, "gs://my-bucket")
if err != nil {
	return err
}

_, err = bucket.Write(ctx, "packages/example.txt", strings.NewReader("content"))
if err != nil {
	return err
}

reader, err := bucket.Open(ctx, "packages/example.txt")
if err != nil {
	return err
}
defer reader.Close()

Write returns the number of bytes uploaded and sends each object as one non-resumable media upload. Retrying after a failed request starts the upload again.

Open, Exists, Delete, and Size operate on individual object names. Open and Size return ErrNotFound for a missing object; Delete accepts one. ListPrefix reads object metadata by prefix, while UsedSpace reads every object page with only the size field and takes time proportional to the object count.

Authentication

OpenBucket reads Application Default Credentials from attached service accounts on GKE, GCE, and Cloud Run. It also reads a file selected by GOOGLE_APPLICATION_CREDENTIALS or local credentials created by gcloud auth application-default login.

Signed URLs

SignedURL generates a V2 signed URL with a service-account private key when the credential file contains one. For Workload Identity and impersonated credentials, signing calls the IAM Credentials signBlob API and requires permission to sign blobs. The method returns ErrSignedURLUnsupported for the emulator and plain user credentials that do not impersonate a service account.

Emulator

Set STORAGE_EMULATOR_HOST to the address of a Cloud Storage emulator. The value may include an http:// or https:// scheme.

License

MIT.

About

Lightweight Google Cloud Storage client for Go

git-pkgs.dev

Topics

cloud-storagegcsgit-pkgsgogolanggoogle-cloud-storageobject-storage

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity
Custom properties

Stars

4 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.