[GH-ISSUE #631] Support to upload file using signed url, getting 404 #112

Closed
opened 2026-03-03 12:08:23 +03:00 by kerem · 6 comments
Owner

Originally created by @ratnesh93 on GitHub (Dec 9, 2021).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/631

Using generate_upload_signed_url(), I am able to generate signed url which is needed to upload the file,
for gcp I am able to upload using curl -X PUT -H 'Content-Type: text/csv' --data-binary @file_name.csv 'signed_url'
But using emular I am not able to upload, its throwing 404

 `storage_1       | time="2021-12-09T10:25:15Z" level=info msg="172.19.0.1 - - [09/Dec/2021:10:25:15 +0000] \"PUT /storage/v1/b/bucket-name/o/file_name.csv?X-Goog-Algorithm=xxx&X-Goog-Credential=xxx&X-Goog-Date=xxx&X-Goog-Expires=1800&X-Goog-SignedHeaders=content-type%3Bhost&X-Goog-Signature=xxx 
HTTP/1.1\" 404 59"`

I have created storage/data/bucket-name folder.

Can anyone guide me, I am doing something wrong, or emulartor does not support upload using signed url.

Please add support to upload file to signed url.

Originally created by @ratnesh93 on GitHub (Dec 9, 2021). Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/631 Using `generate_upload_signed_url()`, I am able to generate signed url which is needed to upload the file, for gcp I am able to upload using `curl -X PUT -H 'Content-Type: text/csv' --data-binary @file_name.csv 'signed_url'` But using emular I am not able to upload, its throwing 404 ``` `storage_1 | time="2021-12-09T10:25:15Z" level=info msg="172.19.0.1 - - [09/Dec/2021:10:25:15 +0000] \"PUT /storage/v1/b/bucket-name/o/file_name.csv?X-Goog-Algorithm=xxx&X-Goog-Credential=xxx&X-Goog-Date=xxx&X-Goog-Expires=1800&X-Goog-SignedHeaders=content-type%3Bhost&X-Goog-Signature=xxx HTTP/1.1\" 404 59"` ``` I have created `storage/data/bucket-name` folder. Can anyone guide me, I am doing something wrong, or emulartor does not support upload using signed url. Please add support to upload file to signed url.
kerem 2026-03-03 12:08:23 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@fsouza commented on GitHub (Dec 9, 2021):

Hmm curious on why it's using PUT. Can you share a snippet of code reproducing the issue? Which SDK are you using? node.js?

Thanks for reporting!

<!-- gh-comment-id:990255497 --> @fsouza commented on GitHub (Dec 9, 2021): Hmm curious on why it's using `PUT`. Can you share a snippet of code reproducing the issue? Which SDK are you using? node.js? Thanks for reporting!
Author
Owner

@ratnesh93 commented on GitHub (Dec 10, 2021):

I am using it in python code, code sample is under python section in google docs for
Creating a signed URL to upload an object

Code snippet for upload from google docs which I am using :

        url = blob.generate_signed_url(
        version="v4",
        expiration=datetime.timedelta(minutes=15),
        # Allow PUT requests using this URL.
        method="PUT",
        content_type="application/octet-stream",
           )

MyUseCase: generating signed url for uploading file in gcp, I was using emulator for development purpose via docker image for storage.

And while calling above
generate_upload_signed_url_v4(bucket_name,blob_name)

I am able to generate signed url, and when I am trying to upload using postman or curl command from that signed url

curl -X PUT -H 'Content-Type: text/csv' --data-binary @file_name.csv 'signed_url'

I was getting error:
storage_1 | time="2021-12-09T10:25:15Z" level=info msg="172.19.0.1 - - [09/Dec/2021:10:25:15 +0000] \"PUT /storage/v1/b/bucket-name/o/file_name.csv?X-Goog-Algorithm=xxx&X-Goog-Credential=xxx&X-Goog-Date=xxx&X-Goog-Expires=1800&X-Goog-SignedHeaders=content-type%3Bhost&X-Goog-Signature=xxx HTTP/1.1\" 404 59"

<!-- gh-comment-id:990656608 --> @ratnesh93 commented on GitHub (Dec 10, 2021): I am using it in **python** code, code sample is under python section in [google docs](https://cloud.google.com/storage/docs/access-control/signing-urls-with-helpers#storage-signed-url-object-python) for **Creating a signed URL to upload an object** Code snippet for upload from google docs which I am using : ```python url = blob.generate_signed_url( version="v4", expiration=datetime.timedelta(minutes=15), # Allow PUT requests using this URL. method="PUT", content_type="application/octet-stream", ) ``` MyUseCase: generating signed url for uploading file in gcp, I was using emulator for development purpose via docker image for storage. And while calling above ` generate_upload_signed_url_v4(bucket_name,blob_name)` I am able to generate signed url, and when I am trying to upload using postman or curl command from that signed url `curl -X PUT -H 'Content-Type: text/csv' --data-binary @file_name.csv 'signed_url'` I was getting **error**: `storage_1 | time="2021-12-09T10:25:15Z" level=info msg="172.19.0.1 - - [09/Dec/2021:10:25:15 +0000] \"PUT /storage/v1/b/bucket-name/o/file_name.csv?X-Goog-Algorithm=xxx&X-Goog-Credential=xxx&X-Goog-Date=xxx&X-Goog-Expires=1800&X-Goog-SignedHeaders=content-type%3Bhost&X-Goog-Signature=xxx HTTP/1.1\" 404 59"`
Author
Owner

@fsouza commented on GitHub (Dec 10, 2021):

Oh I see I didn't realize GCS supported PUT for uploads too.

We need to update the emulator to support that. Should be a simple change, I'll give it a shot.

<!-- gh-comment-id:990962005 --> @fsouza commented on GitHub (Dec 10, 2021): Oh I see I didn't realize GCS supported `PUT` for uploads too. We need to update the emulator to support that. _Should_ be a simple change, I'll give it a shot.
Author
Owner

@toadjaune commented on GitHub (Apr 5, 2022):

Actually, it is already supported : https://github.com/fsouza/fake-gcs-server/blob/main/fakestorage/server.go#L266

<!-- gh-comment-id:1088555916 --> @toadjaune commented on GitHub (Apr 5, 2022): Actually, it is already supported : https://github.com/fsouza/fake-gcs-server/blob/main/fakestorage/server.go#L266
Author
Owner

@fsouza commented on GitHub (Apr 5, 2022):

Oh yeah that's a good point, thanks for updating the docs!

<!-- gh-comment-id:1089274371 --> @fsouza commented on GitHub (Apr 5, 2022): Oh yeah that's a good point, thanks for updating the docs!
Author
Owner

@fsouza commented on GitHub (Apr 5, 2022):

@ratnesh93 can you check if the instructions in #736 work for you?

<!-- gh-comment-id:1089328082 --> @fsouza commented on GitHub (Apr 5, 2022): @ratnesh93 can you check if the instructions in #736 work for you?
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#112
No description provided.