[GH-ISSUE #429] Issue with downloading image file #85

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

Originally created by @nhatmvo on GitHub (Feb 17, 2021).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/429

After I uploaded a file into server successfully, when downloaded that file using curl, I cannot open that file (the file is damaged or corrupted). I even used docker cp to move that file from storage/<my-bucket> within fake-gcs-server container into my host machine, but I still cannot open it neither.
Is this intended or my request is missing something?

here is my request:

curl --location --request POST 'https://0.0.0.0:4443/upload/storage/v1/b/sample-bucket/o?uploadType=media&name=tux.png' \
--header 'Content-Type: image/png' \
--data-binary '@/Users/nhatvm/Downloads/Tux.png'

and download it using:

curl -X GET 
  -o "Desktop/tux.png" 
  -k "https://0.0.0.0:4443/storage/v1/b/sample-bucket/o/tux.png"

and this happened when I tried to upload image file (png, jpeg, ...), with text file it's ok

Originally created by @nhatmvo on GitHub (Feb 17, 2021). Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/429 After I uploaded a file into server successfully, when downloaded that file using curl, I cannot open that file (the file is damaged or corrupted). I even used `docker cp` to move that file from `storage/<my-bucket>` within fake-gcs-server container into my host machine, but I still cannot open it neither. Is this intended or my request is missing something? here is my request: ``` curl --location --request POST 'https://0.0.0.0:4443/upload/storage/v1/b/sample-bucket/o?uploadType=media&name=tux.png' \ --header 'Content-Type: image/png' \ --data-binary '@/Users/nhatvm/Downloads/Tux.png' ``` and download it using: ``` curl -X GET -o "Desktop/tux.png" -k "https://0.0.0.0:4443/storage/v1/b/sample-bucket/o/tux.png" ``` and this happened when I tried to upload image file (png, jpeg, ...), with text file it's ok
kerem 2026-03-03 12:08:08 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@fsouza commented on GitHub (Feb 17, 2021):

Are you using the filesystem storage backend? If so, I think this is the same as #296 🤔 Need to investigate it further to check what's going on.

<!-- gh-comment-id:780720148 --> @fsouza commented on GitHub (Feb 17, 2021): Are you using the filesystem storage backend? If so, I think this is the same as #296 🤔 Need to investigate it further to check what's going on.
Author
Owner

@nhatmvo commented on GitHub (Feb 17, 2021):

No, just a normal image file file from the internet, I used postman for testing, and the content type is returned correctly, so probably it's not the same as the issue you mentioned about.

<!-- gh-comment-id:780730835 --> @nhatmvo commented on GitHub (Feb 17, 2021): No, just a normal image file file from the internet, I used postman for testing, and the content type is returned correctly, so probably it's not the same as the issue you mentioned about.
Author
Owner

@fsouza commented on GitHub (Feb 17, 2021):

@nhatmvo oh, I mean which backend within fake-gcs-server. What's the command you used to start fake-gcs-server?

<!-- gh-comment-id:780731522 --> @fsouza commented on GitHub (Feb 17, 2021): @nhatmvo oh, I mean which backend within fake-gcs-server. What's the command you used to start fake-gcs-server?
Author
Owner

@nhatmvo commented on GitHub (Feb 17, 2021):

I use exactly the command from README.md.

<!-- gh-comment-id:780732879 --> @nhatmvo commented on GitHub (Feb 17, 2021): I use exactly the command from README.md.
Author
Owner

@fsouza commented on GitHub (Feb 17, 2021):

Can you try with -backend memory and check if the error persists?

docker run -d --name fake-gcs-server -p 4443:4443 fsouza/fake-gcs-server -backend memory
<!-- gh-comment-id:780736989 --> @fsouza commented on GitHub (Feb 17, 2021): Can you try with `-backend memory` and check if the error persists? ``` docker run -d --name fake-gcs-server -p 4443:4443 fsouza/fake-gcs-server -backend memory ```
Author
Owner

@Sytten commented on GitHub (Jun 28, 2021):

I think its because the url is missing a query param correctly, it should be: https://0.0.0.0:4443/storage/v1/b/sample-bucket/o/tux.png?alt=media

<!-- gh-comment-id:869897874 --> @Sytten commented on GitHub (Jun 28, 2021): I think its because the url is missing a query param correctly, it should be: `https://0.0.0.0:4443/storage/v1/b/sample-bucket/o/tux.png?alt=media`
Author
Owner

@BlackBeardBana commented on GitHub (Jun 7, 2023):

Would it be possible to support the same functionality without the need for the query param? ?alt=media

<!-- gh-comment-id:1580826749 --> @BlackBeardBana commented on GitHub (Jun 7, 2023): Would it be possible to support the same functionality without the need for the query param? `?alt=media`
Author
Owner

@fsouza commented on GitHub (Jun 7, 2023):

Would it be possible to support the same functionality without the need for the query param? ?alt=media

For that, you'd need to use the download URL. You're making a call to the Objects: get API and it requires ?alt=media to serve object data.

<!-- gh-comment-id:1580849441 --> @fsouza commented on GitHub (Jun 7, 2023): > Would it be possible to support the same functionality without the need for the query param? ?alt=media For that, you'd need to use the download URL. You're making a call to the [Objects: get](https://cloud.google.com/storage/docs/json_api/v1/objects/get) API and it requires ?alt=media to serve object data.
Author
Owner

@BlackBeardBana commented on GitHub (Aug 1, 2023):

@fsouza
Thanks for the response, what would the download URL look like?

I can reach the object data through the browser via:

and I've tried:

to download the image but both endpoints return a 404.

Any help would be appreciated.

<!-- gh-comment-id:1660162681 --> @BlackBeardBana commented on GitHub (Aug 1, 2023): @fsouza Thanks for the response, what would the download URL look like? I can reach the object data through the browser via: - https://localhost:4443/storage/v1/b/image-bucket/o/folder/image.jpg and I've tried: - https://localhost:4443/image-bucket/folder/image.jpg - https://localhost:4443/download/storage/v1/b/iimage-bucket/0/folder/image.jpg to download the image but both endpoints return a 404. Any help would be appreciated.
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#85
No description provided.