Skip to content
Google Cloud Storage emulator & testing library.
Go Shell Dockerfile
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows github/workflows/main: no need to pass ./... to golangci-lint Sep 16, 2019
ci ci/run-python-example: remove redundant variables Aug 30, 2019
examples build(deps): bump urllib3 from 1.25.3 to 1.25.5 in /examples/python Sep 20, 2019
fakestorage fakestorage: make linter happy Aug 2, 2019
internal fakestorage: add support for ContentType Aug 2, 2019
testdata Add some tests for generateObjectsFromFiles and simplify it Jul 18, 2019
.dockerignore Clean-up dockerignore Jul 18, 2019
.gitignore main: make server configurable Jul 18, 2019
.golangci.yaml golangci: disable funlen on tests Sep 15, 2019
Dockerfile Go 1.13 is out, bye Go 1.11! :D Sep 3, 2019
LICENSE license: add 2019 Jan 2, 2019
README.md readme: update gh actions badges Aug 25, 2019
go.mod
go.sum go mod tidy Sep 17, 2019
main.go main: don't exit with error on -h Aug 1, 2019
main_test.go Add some tests for generateObjectsFromFiles and simplify it Jul 18, 2019

README.md

fake-gcs-server

Build Status Build Status GoDoc

fake-gcs-server provides an emulator for Google Cloud Storage API. It can be used as a library in Go projects and/or as a standalone binary/Docker image.

The library is available inside the package github.com/fsouza/fake-gcs-server/fakestorage and can be used from within test suites in Go package. The emulator is available as a binary that can be built manually, downloaded from the releases page or pulled from Docker Hub (docker pull fsouza/fake-gcs-server).

Using the emulator in Docker

If you want to run a standalone server (like the datastore/pubsub emulators) for integration tests and/or tests in other languages you may want to run the fake-gcs-server inside a Docker container:

docker run -d --name fake-gcs-server -p 4443:4443 fsouza/fake-gcs-server

Preload data

In case you want to preload some data in fake-gcs-server just mount a folder in the container at /data:

docker run -d --name fake-gcs-server -p 4443:4443 -v ${PWD}/examples/data:/data fsouza/fake-gcs-server

Where the content of ${PWD}/examples/data is something like:

.
└── sample-bucket
    └── some_file.txt

To make sure everything works as expected you can execute these commands:

curl --insecure https://0.0.0.0:4443/storage/v1/b
{"kind":"storage#buckets","items":[{"kind":"storage#bucket","id":"sample-bucket","name":"sample-bucket"}],"prefixes":null}

curl --insecure https://0.0.0.0:4443/storage/v1/b/sample-bucket/o
{"kind":"storage#objects","items":[{"kind":"storage#object","name":"some_file.txt","id":"sample-bucket/some_file.txt","bucket":"sample-bucket","size":"33"}],"prefixes":[]}

This will result in one bucket called sample-bucket containing one object called some_file.txt.

Example with the Python client library

For Python examples, check out the examples/python directory.

Building the image locally

You may use docker build to build the image locally instead of pulling it from Docker Hub:

docker build -t fsouza/fake-gcs-server .
You can’t perform that action at this time.