mirror of
https://github.com/fsouza/fake-gcs-server.git
synced 2026-04-25 21:55:56 +03:00
[GH-ISSUE #422] Correct way to call multi-part request #84
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#84
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 @nhatmvo on GitHub (Feb 15, 2021).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/422
I use postman to test the gcs and this is my curl:
curl --location --request POST 'https://localhost:4443/upload/storage/v1/b/sample-bucket/o?uploadType=multipart&name=readme.txt' \ --header 'Content-Type: multipart/form-data' \ --form 'file=@"<FileLocation>"'The content of my file is:
Sample textand the response keep telling me that:
So, what is the correct way to send multi-part request into your gcs-server? I tried uploadType=media and it works perfectly fine
@fsouza commented on GitHub (Feb 15, 2021):
Google Cloud Storage doesn't support
form-data. The emulator matches the GCS API. This page should have more information: https://cloud.google.com/storage/docs/uploading-objects#rest-upload-objects@nhatmvo commented on GitHub (Feb 15, 2021):
Hi @fsouza, thank you so much for a quick reply.
Anyway, I changed the Content-Type into another value, and my request is:
curl --location --request POST 'https://localhost:4443/upload/storage/v1/b/sample-bucket/o?uploadType=multipart&name=readme.txt' \ --header 'Content-Type: text/plain;boundary=test' \ --data-binary '<FileLocation>'but I get this error:
I'm wondering what's wrong with my request this time :(
Thank you!
@fsouza commented on GitHub (Feb 15, 2021):
The body must contain metadata in json format separated by the boundary: https://cloud.google.com/storage/docs/uploading-objects#single-request-upload-that-includes-object-metadata (this link will let you fill-in the data)
So in your case your file would need to have content that looks something like this (untested):
@nhatmvo commented on GitHub (Feb 15, 2021):
Thank you so much!