[PR #1976] [MERGED] Added support from gcloud cli resumable uploads #1985

Closed
opened 2026-03-03 12:37:06 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/fsouza/fake-gcs-server/pull/1976
Author: @danieldanieltata
Created: 6/8/2025
Status: Merged
Merged: 2/4/2026
Merged by: @fsouza

Base: mainHead: add-support-for-gcloud-cli-resumable


📝 Commits (10+)

📊 Changes

7 files changed (+386 additions, -1 deletions)

View changed files

📝 .github/workflows/main.yml (+3 -0)
ci/run-gcloud-example.sh (+11 -0)
examples/gcloud/gcloud-example.sh (+26 -0)
examples/gcloud/image.png (+0 -0)
📝 fakestorage/response.go (+2 -0)
📝 fakestorage/upload.go (+145 -1)
📝 fakestorage/upload_test.go (+199 -0)

📄 Description

Problem

The gcloud CLI uses a different approach for resumable uploads when streaming data that wasn't previously supported by fake-gcs-server. When using commands like:
tar -czf - examples/gcloud/image.png | gcloud storage cp - gs://fake-bucket/image.tar.gz
The gcloud CLI performs "body-based resumable uploads" where the object metadata (name, content-type, etc.) is sent in the request body as JSON, rather than as query parameters or headers. This caused streaming operations from gcloud CLI to fail against fake-gcs-server.

Changes Made

  • Added body-based resumable upload support - Implemented handleBodyBasedResumableUpload function in upload.go with comprehensive test coverage for gcloud CLI compatibility.
  • Fixed CacheControl field bug - Added missing CacheControl field to objectResponse struct in response.go that was affecting all cache control functionality.
  • Created gcloud CLI example - Created gcloud-example.sh to explain how to use gcloud CLI with fake-gcs-server

This is my first time writing in Go. I noticed this functionality was missing and wanted to contribute. I used the help of AI to guide me through some parts of the implementation and writing. Let me know if there’s anything I can improve or if there are any Go best practices I should follow 🙂.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/fsouza/fake-gcs-server/pull/1976 **Author:** [@danieldanieltata](https://github.com/danieldanieltata) **Created:** 6/8/2025 **Status:** ✅ Merged **Merged:** 2/4/2026 **Merged by:** [@fsouza](https://github.com/fsouza) **Base:** `main` ← **Head:** `add-support-for-gcloud-cli-resumable` --- ### 📝 Commits (10+) - [`1ff0b71`](https://github.com/fsouza/fake-gcs-server/commit/1ff0b717d3e62227a97787436993c62bf7fb2746) Added support from gcloud cli resumable uploads - [`1d68241`](https://github.com/fsouza/fake-gcs-server/commit/1d68241aa75709d65788434c01c34e44a5d6926a) Update mux_transport.go - [`6e48a66`](https://github.com/fsouza/fake-gcs-server/commit/6e48a66ee7fd5eb69d1ee50100bfa5b61f04514f) Update mux_transport.go - [`fddb421`](https://github.com/fsouza/fake-gcs-server/commit/fddb4211797b72038557abbaa545cbd61260aefe) Update mux_transport.go - [`341e5fe`](https://github.com/fsouza/fake-gcs-server/commit/341e5feafdf55b5c9af3863b2c85d3100402d984) Update mux_transport.go - [`3e7ad7c`](https://github.com/fsouza/fake-gcs-server/commit/3e7ad7c1eb90cbfb20bed8a01b1c99793f07f0a1) Update server.go - [`d71c5e0`](https://github.com/fsouza/fake-gcs-server/commit/d71c5e03bfe5ad2d1dc589167847c3fbf6c9854a) Update server.go - [`2265ee7`](https://github.com/fsouza/fake-gcs-server/commit/2265ee7e79d249ceeef87c4f6e0f96b4a1ac5844) Update server.go - [`fb913d1`](https://github.com/fsouza/fake-gcs-server/commit/fb913d18ef66652b26244fd71235346b96d95876) Update server_test.go - [`0d5fa78`](https://github.com/fsouza/fake-gcs-server/commit/0d5fa78b33aa1505b5efd3730d4c2714ee67cc47) Update server_test.go ### 📊 Changes **7 files changed** (+386 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/main.yml` (+3 -0) ➕ `ci/run-gcloud-example.sh` (+11 -0) ➕ `examples/gcloud/gcloud-example.sh` (+26 -0) ➕ `examples/gcloud/image.png` (+0 -0) 📝 `fakestorage/response.go` (+2 -0) 📝 `fakestorage/upload.go` (+145 -1) 📝 `fakestorage/upload_test.go` (+199 -0) </details> ### 📄 Description **Problem** The gcloud CLI uses a different approach for resumable uploads when streaming data that wasn't previously supported by fake-gcs-server. When using commands like: `tar -czf - examples/gcloud/image.png | gcloud storage cp - gs://fake-bucket/image.tar.gz ` The gcloud CLI performs "body-based resumable uploads" where the object metadata (name, content-type, etc.) is sent in the request body as JSON, rather than as query parameters or headers. This caused streaming operations from gcloud CLI to fail against fake-gcs-server. **Changes Made** - [x] **Added body-based resumable upload support -** Implemented `handleBodyBasedResumableUpload` function in `upload.go` with comprehensive test coverage for gcloud CLI compatibility. - [X] **Fixed CacheControl field bug -** Added missing CacheControl field to objectResponse struct in `response.go` that was affecting all cache control functionality. - [X] **Created gcloud CLI example -** Created `gcloud-example.sh` to explain how to use gcloud CLI with fake-gcs-server This is my first time writing in Go. I noticed this functionality was missing and wanted to contribute. I used the help of AI to guide me through some parts of the implementation and writing. Let me know if there’s anything I can improve or if there are any Go best practices I should follow 🙂. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-03 12:37:06 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/fake-gcs-server#1985
No description provided.