Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cloud Storage] Error when uploading an empty file. #190

Open
szgupta opened this issue Aug 29, 2023 · 1 comment
Open

[Cloud Storage] Error when uploading an empty file. #190

szgupta opened this issue Aug 29, 2023 · 1 comment

Comments

@szgupta
Copy link

szgupta commented Aug 29, 2023

Hi there! I was using the cloud storage API to upload an empty file to GCS and got the following error:

HTTP status client error (411 Length Required) for url (https://storage.googleapis.com/upload/storage/v1/b/bucket-name/o?uploadType=media&name=hello_world.txt)

I was able to get around it by explicitly setting the Media::content_length property to Some(0) when the data was empty.

I couldn't track it down in GCP docs, but is it known that the content-length header must be set (with a value of 0) if uploading an empty file? And if so, should this be implemented within the cloud-storage crate (i.e. at the library level)?

@yoshidan
Copy link
Owner

yoshidan commented Sep 1, 2023

Since the library for Golang is able to upload even 0 bytes without explicitly specifying content-length, we think it would be better to automatically set content-length: 0 inside the library.
After investigation, it seems that we can get the size of the body with zero-copy, so we will implement it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants