mirror of
https://github.com/fsouza/fake-gcs-server.git
synced 2026-04-25 21:55:56 +03:00
[GH-ISSUE #861] Uploaded files are not accessible by their URL #138
Labels
No labels
bug
compatibility-issue
docker
documentation
enhancement
help wanted
needs information
pull-request
question
stale
unfortunate
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/fake-gcs-server#138
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @markvital on GitHub (Jul 19, 2022).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/861
Hi,
I'm running the GCS emulator following the instructions in README.
I created the following directory structure:
I run the emulator using the following command:
Everething works great, the bucket is created and I can see some objects there, as expected:
When I connect to the docker container via terminal I can see the files in
/storagefolder as well.But when I try to access objects directly via URL, I get
Not Foundstatus.What am I doing wrong?
@tobilen commented on GitHub (Jul 25, 2022):
took me a while too:
http://localhost:4443/storage/v1/b/<BUCKET_NAME>/o/<OBJECT_NAME>?alt=mediamight not need the
alt=mediafor text. i've only been using it for images@fsouza commented on GitHub (Aug 14, 2022):
@markvital that should work (
${scheme}://${public-host}/${bucket}/${object}points to the downloadObject handler). Can you share all the logs from the server process?(apologies for the delayed response, I was out on a long break, but I'm back, so you can expect faster responses now!)
@lauslim12 commented on GitHub (Aug 18, 2022):
I have the same problem.
I hosted this Fake GCS Server on my Raspberry Pi in my local network, so the URL is a bit different. Instead of
localhost:4443I am going to use192.168.1.2:4443. When I try to accesshttp://192.168.1.2:4443/storage/v1/<BUCKET_NAME>/<OBJECT_NAME>, I got the sameNot Founderror.I have to edit the URL to be like this format:
http://192.168.1.2:4443/storage/v1/b/<BUCKET_NAME>/o/<OBJECT_NAME>for it to display the correct object metadata. This is just rendering the metadata! As I'm storing images, I have to add a suffix:?alt=mediato make it render in my web browser.In short, to display an image stored to this Fake GCS Server, I have to use the following URL format:
I have not yet tested about the right URL format to display images from the real Google Cloud Storage, but the last time I checked it, it's still in the same format:
https://storage.googleapis.com/storage/v1/(this was a long time ago, but let me check again later).@fsouza commented on GitHub (Aug 18, 2022):
Gotcha. In that case you need to pass
-public-host 192.168.1.2:4443to the process. fake-gcs-server validates the host too for those "public" URLs.@lauslim12 commented on GitHub (Aug 18, 2022):
Thank you for your reply! I have tested with
-public-host 192.168.1.2:4443, but it seems that the problem is not yet fixed. It still returnsNot Foundupon accessing the expected URL.I still have to add an
obefore the object name, so it's stillhttp://192.168.1.2:4443/storage/v1/b/<BUCKET>/o/<OBJECT>. My expected URL is actuallyhttp://192.168.1.2:4443/storage/v1/b/<BUCKET>/<OBJECT>(without the/o/addition), so I can instantly access the image in my browser.My question, is adding of
/o/an expected behavior, or is it a side effect from somewhere?Thank you very much for your kind help.
@fsouza commented on GitHub (Aug 18, 2022):
Is that URL valid in the GCS API?
Once you set
-public-host 192.168.1.2:4443, the URLhttp://192.168.1.2:4443/<BUCKET>/<OBJECT>should work.As far as I understand:
http://192.168.1.2:4443/storage/v1/b/<BUCKET>/o/<OBJECT>is the API URL, which works in fake-gcs-server, but in real GCS would require authentication (replacing 192.168.1.2:4443 with storage.googleapis.com)http://192.168.1.2:4443/<BUCKET>/<OBJECT>is the public URL for the object, which works in fake-gcs-server and in GCS (as long as the bucket and/or object is public - and also replacing 192.168.1.2:4443 with storage.googleapis.com).http://192.168.1.2:4443/storage/v1/b/<BUCKET>/<OBJECT>is not a valid URL@lauslim12 commented on GitHub (Aug 18, 2022):
Ahhh, I see. I just found out about it by reading your answer and looking at Google Cloud Storage's documentation. It appears that my expected URL (
http://192.168.1.2:4443/storage/v1/b/<BUCKET>/<OBJECT>) is not a valid URL. It appears that I made a mistake in thinking that was a valid URL! Sorry!I fixed it and have executed the Docker image with
-public-host 192.168.1.2:4443and the image shows perfectly in my browser by following your second URL (http://192.168.1.2:4443/<BUCKET>/<OBJECT>).Once again, thank you for your kind help, @fsouza!
For the people after me who are maybe planning to run this via a Docker Compose, here's my configuration:
Hopefully this helps anyone who encountered the same issue!
@fsouza commented on GitHub (Aug 18, 2022):
Thanks for sharing your setup. I'll close the issue, but please let me know if we should keep it open or feel free to open another one in the future if you run into any other issues!
@markvital commented on GitHub (Aug 19, 2022):
No problem, it actually worked for me after I deleted and restarted docker container.
Thank you so much for helping 🙏