[GH-ISSUE #992] Not able to mimic Fake GCS Storage #153

Open
opened 2026-03-03 12:08:46 +03:00 by kerem · 3 comments
Owner

Originally created by @sourabhsparkala on GitHub (Nov 21, 2022).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/992

Hello All,

I am new to GOLang development

I am trying to setup GCP Emulator

First I started the server as stated in various examples

opts := fakestorage.Options{
		InitialObjects: []fakestorage.Object{
			{
				ObjectAttrs: fakestorage.ObjectAttrs{
					BucketName: TestBucket,
					Name:       "module/file1",
				},
			},
			{
				ObjectAttrs: fakestorage.ObjectAttrs{
					BucketName: TestBucket,
					Name:       "module/file2",
				},
			},
		},
		StorageRoot: "/test",
		Scheme:      "http",
		Host:        "localhost",
		Port:        9000,
	}
	server, err := fakestorage.NewServerWithOptions(opts)

I also set this

os.Setenv("STORAGE_EMULATOR_HOST", fmt.Sprintf("%s:%s", "http://localhost", "9000"))

I am assumed that by doing so, a new server would be hosted in localhost:9000 and point the StorageRoot folder path as the new storage folder.

And when I call this below method to list the objects found inside StorageRoot i.e /test/module. I do not get any objects.

client, err := storage.NewClient(cctx)

it := client.Bucket(message.Bucket).Objects(cctx, &storage.Query{
		Prefix: strings.Split(message.Name, "/")[0] + "/module/",
		// Delimiter: "_",
	})

Your insights would be helpful.

Originally created by @sourabhsparkala on GitHub (Nov 21, 2022). Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/992 Hello All, I am new to GOLang development I am trying to setup GCP Emulator First I started the server as stated in various examples ``` opts := fakestorage.Options{ InitialObjects: []fakestorage.Object{ { ObjectAttrs: fakestorage.ObjectAttrs{ BucketName: TestBucket, Name: "module/file1", }, }, { ObjectAttrs: fakestorage.ObjectAttrs{ BucketName: TestBucket, Name: "module/file2", }, }, }, StorageRoot: "/test", Scheme: "http", Host: "localhost", Port: 9000, } server, err := fakestorage.NewServerWithOptions(opts) ``` I also set this ``` os.Setenv("STORAGE_EMULATOR_HOST", fmt.Sprintf("%s:%s", "http://localhost", "9000")) ``` I am assumed that by doing so, a new server would be hosted in localhost:9000 and point the `StorageRoot` folder path as the new storage folder. And when I call this below method to list the objects found inside `StorageRoot` i.e `/test/module`. I do not get any objects. ``` client, err := storage.NewClient(cctx) it := client.Bucket(message.Bucket).Objects(cctx, &storage.Query{ Prefix: strings.Split(message.Name, "/")[0] + "/module/", // Delimiter: "_", }) ``` Your insights would be helpful.
Author
Owner

@klyubavsky commented on GitHub (Jun 11, 2023):

Hi, @fsouza

Could you take a look on this issue? I'm facing the same. After environment variable "STORAGE_EMULATOR_HOST" being set client can't find object in storage, as fakestorage server responds 404.

<!-- gh-comment-id:1586320678 --> @klyubavsky commented on GitHub (Jun 11, 2023): Hi, @fsouza Could you take a look on this issue? I'm facing the same. After environment variable "STORAGE_EMULATOR_HOST" being set client can't find object in storage, as fakestorage server responds 404.
Author
Owner

@klyubavsky commented on GitHub (Jun 12, 2023):

All of a sudden my case was completely fixed after switching from Host to PublicHost.
@sourabhsparkala I believe yours will be also
@fsouza maybe include an example with STORAGE_EMULATOR_HOST env var in documentation?

<!-- gh-comment-id:1587884418 --> @klyubavsky commented on GitHub (Jun 12, 2023): All of a sudden my case was completely fixed after switching from `Host` to `PublicHost`. @sourabhsparkala I believe yours will be also @fsouza maybe include an example with STORAGE_EMULATOR_HOST env var in documentation?
Author
Owner

@pocockn commented on GitHub (Jan 19, 2024):

@klyubavsky I'm seeing this issue, could you show an example of working config please

<!-- gh-comment-id:1901137889 --> @pocockn commented on GitHub (Jan 19, 2024): @klyubavsky I'm seeing this issue, could you show an example of working config please
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#153
No description provided.