Cloud Storage
REST · port 4443
Configuration
Set the emulator host environment variable:
$ export STORAGE_EMULATOR_HOST=localhost:4443 # or use: eval $(localgcp env)
The Go, Python, Java, and Node.js Cloud Storage client libraries all respect this env var and will connect to localgcp automatically.
Go SDK example
Create a bucket, upload an object, and download it:
package main import ( "context" "fmt" "io" "log" "cloud.google.com/go/storage" ) func main() { ctx := context.Background() // STORAGE_EMULATOR_HOST=localhost:4443 must be set client, err := storage.NewClient(ctx) if err != nil { log.Fatal(err) } defer client.Close() bucket := client.Bucket("my-bucket") // Create bucket if err := bucket.Create(ctx, "my-project", nil); err != nil { log.Fatal(err) } // Upload an object w := bucket.Object("hello.txt").NewWriter(ctx) fmt.Fprint(w, "Hello, localgcp!") if err := w.Close(); err != nil { log.Fatal(err) } // Download the object r, err := bucket.Object("hello.txt").NewReader(ctx) if err != nil { log.Fatal(err) } defer r.Close() data, _ := io.ReadAll(r) fmt.Println(string(data)) // "Hello, localgcp!" }
Features
- Bucket CRUD -- create, get, list, delete buckets
- Object upload -- simple, multipart, and resumable uploads
- Object download -- full content or range reads
- Object operations -- metadata, delete, copy
- Object listing -- with prefix and delimiter (directory-like browsing)
- Signed URLs -- generate and use signed download URLs
- API compatibility -- both JSON API and XML API paths
Signed URLs
localgcp provides a signed URL endpoint for generating pre-signed download URLs:
$ curl -X POST http://localhost:4443/_localgcp/sign \ -H "Content-Type: application/json" \ -d '{"bucket":"my-bucket","object":"hello.txt","ttl_seconds":3600}'
The response contains a signed URL you can use to download the object without authentication. This is useful for testing pre-signed URL flows in your application.
Persistence
By default, all objects are stored in memory. Use --data-dir to persist bucket and object data across restarts:
$ localgcp up --data-dir=./.localgcp
Object data and metadata are stored as files in .localgcp/gcs/.
Not yet supported
- Bucket versioning
- Object compose
- IAM policies
- Notifications