[GH-ISSUE #8] How to use? #2155

Closed
opened 2026-03-15 17:47:19 +03:00 by kerem · 9 comments
Owner

Originally created by @frallain on GitHub (Apr 27, 2018).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/8

Hi, I am really interested by this initiative to mimick GCS a la fakes3. Some questions though,

  • how to start the server?
  • what are the dependencies?
    Cheers
Originally created by @frallain on GitHub (Apr 27, 2018). Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/8 Hi, I am really interested by this initiative to mimick GCS a la fakes3. Some questions though, - how to start the server? - what are the dependencies? Cheers
kerem closed this issue 2026-03-15 17:47:24 +03:00
Author
Owner

@fsouza commented on GitHub (Apr 27, 2018):

@frallain hey, it looks like you want to use this as a standalone server/daemon? fake-gcs-server is a library, you can create a custom application server out of it, but you'd need to write the code to do so.

Not sure if that answers your question. Please let me know if that's not the case! :)

<!-- gh-comment-id:384997655 --> @fsouza commented on GitHub (Apr 27, 2018): @frallain hey, it looks like you want to use this as a standalone server/daemon? fake-gcs-server is a library, you can create a custom application server out of it, but you'd need to write the code to do so. Not sure if that answers your question. Please let me know if that's not the case! :)
Author
Owner

@c1tt1 commented on GitHub (May 2, 2018):

I think it would be better to have make it as standalone daemon or server executable as a rest api service, in that case any programming language can consume it, like how this fake-s3 is implemented . Now as it is only golang developers can use this.

<!-- gh-comment-id:386122183 --> @c1tt1 commented on GitHub (May 2, 2018): I think it would be better to have make it as standalone daemon or server executable as a rest api service, in that case any programming language can consume it, like how this [fake-s3](https://github.com/jubos/fake-s3) is implemented . Now as it is only golang developers can use this.
Author
Owner

@gracenoah commented on GitHub (Aug 6, 2018):

This is how I use it:

package main

import (
	"fmt"

	"github.com/fsouza/fake-gcs-server/fakestorage"
)

func main() {
	server, err := fakestorage.NewServerWithOptions(fakestorage.Options{
		InitialObjects: []fakestorage.Object{
			{
				BucketName: "bucket",
				Name:       "bucket-precreate-object",
				Content:    []byte("This object just forces the bucket to exist when the server starts up."),
			},
		},
		Host:        "0.0.0.0",
		Port:        4443,
		StorageRoot: "/storage",
	})
	if err != nil {
		panic(err)
	}
	fmt.Printf("Server started at %s\n", server.URL())
	select {}
}

I also use it the original intended way as a library with in-memory storage in tests, but this is really useful for integration tests.

<!-- gh-comment-id:410748569 --> @gracenoah commented on GitHub (Aug 6, 2018): This is how I use it: ```go package main import ( "fmt" "github.com/fsouza/fake-gcs-server/fakestorage" ) func main() { server, err := fakestorage.NewServerWithOptions(fakestorage.Options{ InitialObjects: []fakestorage.Object{ { BucketName: "bucket", Name: "bucket-precreate-object", Content: []byte("This object just forces the bucket to exist when the server starts up."), }, }, Host: "0.0.0.0", Port: 4443, StorageRoot: "/storage", }) if err != nil { panic(err) } fmt.Printf("Server started at %s\n", server.URL()) select {} } ``` I also use it the original intended way as a library with in-memory storage in tests, but this is really useful for integration tests.
Author
Owner

@teone commented on GitHub (Mar 27, 2019):

Hi @fsouza,
first thing, thanks for creating this!

I'm trying to use this as a fake backend to create standalone server (as @cllty suggested).
Using @gracenoah suggestion I quickly containerized it and it's running exposing port 9000.

When I run a curl against it I receive a AccessDenied as in:

curl 127.0.0.1:9000/storage/v1/b
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied.</Message><Key>v1/b</Key><BucketName>storage</BucketName><Resource>/storage/v1/b</Resource><RequestId>158FE5F2C8F655B8</RequestId><HostId>7f2ab8aa-98eb-494c-bb79-7d25ec4d7724</HostId></Error>

I couldn't find any reference to credentials in the code, so any guidance on the usage of the server will be much appreciated.

Thanks in advance

<!-- gh-comment-id:477307276 --> @teone commented on GitHub (Mar 27, 2019): Hi @fsouza, first thing, thanks for creating this! I'm trying to use this as a fake backend to create standalone server (as @cllty suggested). Using @gracenoah suggestion I quickly containerized it and it's running exposing port `9000`. When I run a `curl` against it I receive a `AccessDenied` as in: ``` curl 127.0.0.1:9000/storage/v1/b <?xml version="1.0" encoding="UTF-8"?> <Error><Code>AccessDenied</Code><Message>Access Denied.</Message><Key>v1/b</Key><BucketName>storage</BucketName><Resource>/storage/v1/b</Resource><RequestId>158FE5F2C8F655B8</RequestId><HostId>7f2ab8aa-98eb-494c-bb79-7d25ec4d7724</HostId></Error> ``` I couldn't find any reference to credentials in the code, so any guidance on the usage of the server will be much appreciated. Thanks in advance
Author
Owner

@teone commented on GitHub (Mar 27, 2019):

ok, never mind and sorry for the stupid question... I didn't realize the connection was trough https and that's why it was running on port 4443, exposing that port works:

curl --insecure https://127.0.0.1:4443/storage/v1/b
{
  "kind": "storage#buckets",
  "items": [
    {
      "kind": "storage#bucket",
      "ID": "bucket",
      "Name": "bucket"
    }
  ],
  "prefixes": null
}
<!-- gh-comment-id:477309639 --> @teone commented on GitHub (Mar 27, 2019): ok, never mind and sorry for the stupid question... I didn't realize the connection was trough `https` and that's why it was running on port `4443`, exposing that port works: ``` curl --insecure https://127.0.0.1:4443/storage/v1/b { "kind": "storage#buckets", "items": [ { "kind": "storage#bucket", "ID": "bucket", "Name": "bucket" } ], "prefixes": null } ```
Author
Owner

@fsouza commented on GitHub (Mar 28, 2019):

Hey @teone, I think I'll implement a fake--gcs command and containerize that to facilitate testing applications that are not using Go. And would include some docs too. Would that be helpful?

<!-- gh-comment-id:477652847 --> @fsouza commented on GitHub (Mar 28, 2019): Hey @teone, I think I'll implement a fake--gcs command and containerize that to facilitate testing applications that are not using Go. And would include some docs too. Would that be helpful?
Author
Owner

@teone commented on GitHub (Mar 28, 2019):

@fsouza I was waiting to arrive to a more stable point with that but I started looking at that yesterday: https://github.com/teone/gc-fake-storage I'd be happy to contribute this back here if others are interested in it

<!-- gh-comment-id:477683166 --> @teone commented on GitHub (Mar 28, 2019): @fsouza I was waiting to arrive to a more stable point with that but I started looking at that yesterday: https://github.com/teone/gc-fake-storage I'd be happy to contribute this back here if others are interested in it
Author
Owner

@fsouza commented on GitHub (Mar 28, 2019):

Oh cool, if you have it I can link it in the README too :)

<!-- gh-comment-id:477762720 --> @fsouza commented on GitHub (Mar 28, 2019): Oh cool, if you have it I can link it in the README too :)
Author
Owner

@teone commented on GitHub (Mar 28, 2019):

Sure I'll send you a PR for that as soon as it's in a decent shape!

<!-- gh-comment-id:477765108 --> @teone commented on GitHub (Mar 28, 2019): Sure I'll send you a PR for that as soon as it's in a decent shape!
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#2155
No description provided.