LocalCloud Cloud Storage Emulator
Get started
local.cloud / agents
Read this page as Markdown ↗
local.cloud — Cloud Storage Emulator .md Open tab

Cloud Storage emulator

Cloud Storage stores files as objects inside buckets. Use it for application uploads, datasets, and artifacts that need an object-storage API.

When to use Cloud Storage

Typical uses

Use when your application stores unstructured files and addresses each object by bucket and name, with uploads, downloads, and object metadata handled through an API.

Examples

  • User uploads and downloads
  • Data pipeline inputs and outputs

Explore another service

View all

Example usage

Service ID: gcs. Starts by default. Use an already running LocalCloud runtime for the examples below.

Export the local project and mapped endpoints in your client process, then use the client settings below. First-time setup

# Export GOOGLE_CLOUD_PROJECT and STORAGE_EMULATOR_HOST
eval "$(localcloud env)"

Python

Upload and download an object

Upload and download a text object; Cloud Storage stores application files in addressable buckets.

Create a bucket and round-trip a text object locally.

SDK dependencies

Run in a new example directory

python3 -m venv .venv
source .venv/bin/activate
python -m pip install google-cloud-storage

Save as hello.py

import os
from google.api_core.exceptions import NotFound
from google.auth.credentials import AnonymousCredentials
from google.cloud import storage

assert os.environ['STORAGE_EMULATOR_HOST']
client = storage.Client(
    project=os.environ['GOOGLE_CLOUD_PROJECT'],
    credentials=AnonymousCredentials(),
)
bucket = client.bucket("localcloud-sdk-example")

try:
    bucket.reload()
except NotFound:
    bucket.create()

blob = bucket.blob("data.txt")
blob.upload_from_string("Hello from LocalCloud!")
print(blob.download_as_text())

Run the example

python hello.py

Verify the result

The command completes successfully and prints the expected output shown below.

Expected output

Hello from LocalCloud!
Full example guide

Verify a resource workflow by creating isolated state, performing the operation, and reading the result back. Run cleanup even after a failure; delete only test-owned resources.

Connection failed? Check localcloud status --verbose, enabled services, and client exports. Stop accidental Google Cloud calls; correct local routing before retrying.

Documented workflows

  • Bucket CRUD; object upload, download, listing, and deletion

    Create a bucket, upload a fixture, and assert its downloaded bytes. List and delete owned objects to test cleanup.

  • Bucket IAM and mode-aware object authorization

    Set a bucket policy, then test allowed and denied object requests in the chosen IAM mode through direct listeners and the gateway.

  • Object event delivery to local Pub/Sub topics

    Create a Pub/Sub topic and bucket notification. Upload, update metadata, or delete an object, then assert the event type and object name.

  • HMAC keys and signed XML requests

    Create a service-account HMAC key and sign XML requests. Rotate or revoke it, then assert that the old signature is rejected.

Service boundaries

  • Versioning and archive events await image validation; managed folders are unavailable
  • Lifecycle, retention, holds, and encryption metadata are stored without enforcement
  • Notifications require existing topics; ordering and atomic object/event delivery are not guaranteed
Agent testing

Use Cloud Storage with an AI agent

Before the agent changes application logic, have it create local Cloud Storage state, read it back with the project SDK, and note which feature the check covered. That first local call catches accidental production routing and needs no GCP account, service-account key, or billing project.

Cloud Storage local test

Use LocalCloud to test Cloud Storage locally. Read https://local.cloud/ai/agents.md, set STORAGE_EMULATOR_HOST=http://localhost:5382, create a bucket, upload a small object, list it, download it, and verify content without using real GCP credentials.

Production endpoints, auth, IAM, quotas, regional behavior, and final release validation still need the target Google Cloud project.

Agent resources has more prompts and the AGENTS.md template.

Cloud Storage emulator FAQ

How do I run Cloud Storage locally?

Start LocalCloud using the setup guide, then export its environment in the same terminal as your application.

Which environment variable points the SDK at the local Cloud Storage?

LocalCloud exports STORAGE_EMULATOR_HOST=http://localhost:5382. Use the generated value, because the CLI picks another port when the default is in use. Some SDKs also need explicit client endpoint options; the variable alone does not route them locally.

Does the local Cloud Storage behave exactly like Google Cloud?

No. LocalCloud runs the documented workflows on this page within the service boundaries listed here. Validate behavior against real Cloud Storage before production deployment.

Related guides

Desktop view