fake-gcs-server icon indicating copy to clipboard operation
fake-gcs-server copied to clipboard

gcloud CLI streaming uploads fail due to unsupported body-based resumable uploads

Open danieldanieltata opened this issue 4 months ago • 0 comments

Problem

The gcloud CLI uses a different approach for resumable uploads when streaming data that was not previously supported by fake-gcs-server. For example, when running:

tar -czf - examples/gcloud/image.png | gcloud storage cp - gs://fake-bucket/image.tar.gz

The gcloud CLI performs body-based resumable uploads, where object metadata (name, content-type, etc.) is sent in the request body as JSON, rather than as query parameters or headers. This caused streaming uploads from gcloud CLI to fail against fake-gcs-server.

Steps to Reproduce

  1. Run a streaming upload with gcloud CLI:
echo "test" | gcloud storage cp - gs://fake-bucket/test.txt
  1. Observe that the upload fails due to unsupported body-based resumable upload requests.

Expected Behavior

Streaming uploads from gcloud CLI should work against fake-gcs-server without errors, just like they do with Google Cloud Storage.

Actual Behavior

The server rejects body-based resumable uploads, causing gcloud CLI streaming uploads to fail.

Additional Context

  • This issue blocks using fake-gcs-server as a drop-in replacement for GCS in environments/tests that rely on streaming uploads with gcloud storage cp.
  • Support for body-based resumable uploads would make fake-gcs-server more compatible with real GCS behavior.

Solution

I've already implemented a fix for this issue and opened a PR: #1976. The PR:

  • Adds support for body-based resumable uploads (handleBodyBasedResumableUpload in upload.go).
  • Fixes a missing CacheControl field in the object response struct.
  • Provides an example script (gcloud-example.sh) to demonstrate usage with gcloud CLI. https://github.com/fsouza/fake-gcs-server/pull/1976

danieldanieltata avatar Aug 19 '25 08:08 danieldanieltata