You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
storage: "Failed to parse Content-Range header" when chunk-size upload is used #720
Caused by: com.google.gcloud.storage.StorageException: 400 Bad Request
Failed to parse Content-Range header.
at com.google.gcloud.spi.DefaultStorageRpc.translate(DefaultStorageRpc.java:94)
at com.google.gcloud.spi.DefaultStorageRpc.write(DefaultStorageRpc.java:499)
at com.google.gcloud.storage.BlobWriteChannel$1.run(BlobWriteChannel.java:49)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at com.google.gcloud.RetryHelper.doRetry(RetryHelper.java:181)
at com.google.gcloud.RetryHelper.runWithRetries(RetryHelper.java:247)
at com.google.gcloud.RetryHelper.runWithRetries(RetryHelper.java:237)
at com.google.gcloud.storage.BlobWriteChannel.flushBuffer(BlobWriteChannel.java:46)
at com.google.gcloud.BaseWriteChannel.close(BaseWriteChannel.java:147)
If I uploaded a file with size is exactly 2 x 1024 x 1024, and 1024 x 1024 as the chunk size, then I'll get above exception. However, if I changed the file size to 2 x 1024 x 1024 + 1, then the problem will go away.
Apparently, there is a bug in BlobWriteChannel->flushbuffer, if there is no data available, then there is no need to call options().rpc().write.
Yes, @sudison thank you. We realized that but unfortunately only added a comment in the PR and not here. We are waiting to see if there is a good way to fix that other than applying a workaround to fix it.
My fix for this issue is to add a method:
void totalLength(long length);
on WriteChannel.
The assumption is that, caller knows the length of the file before uploading to GCS.
Indeed that is a way, but I don't think we should make knowing the total lengths a requirement (and GCS should be able to support it). There are various cases where one would not know the length and we would like to support them to.
Agreed. Having to specify the length would make Java NIO integration really hard as NIO users don't give the length before starting their writes via e.g. newOutputStream.
Activity
mziccard commentedon Mar 7, 2016
Hi @sudison thanks for the report. I managed to reproduce you issue, I will look into this and provide a fix as soon as possible.
jean-philippe-martin commentedon Mar 7, 2016
PR #714 has a potential fix for that, making a note to try the repro after that request is merged.
sudison commentedon Mar 7, 2016
I tried the fix in jean-philippe-martin@73b9ef6, I got
com.google.api.client.http.HttpResponseException: 400 Bad Request
{
"error": {
"errors": [
{
"domain": "global",
"reason": "badRequest",
"message": "Invalid Upload Request"
}
],
"code": 400,
"message": "Invalid Upload Request"
}
}
if length is zero, sending a upload request to cloud storage, will get above exception.
aozarov commentedon Mar 7, 2016
Yes, @sudison thank you. We realized that but unfortunately only added a comment in the PR and not here. We are waiting to see if there is a good way to fix that other than applying a workaround to fix it.
sudison commentedon Mar 7, 2016
My fix for this issue is to add a method:
void totalLength(long length);
on WriteChannel.
The assumption is that, caller knows the length of the file before uploading to GCS.
aozarov commentedon Mar 7, 2016
Indeed that is a way, but I don't think we should make knowing the total lengths a requirement (and GCS should be able to support it). There are various cases where one would not know the length and we would like to support them to.
jean-philippe-martin commentedon Mar 7, 2016
Agreed. Having to specify the length would make Java NIO integration really hard as NIO users don't give the length before starting their writes via e.g. newOutputStream.
sudison commentedon Mar 7, 2016
As a user, if I want to use this library now, what should I do? This is the basic requirement for a library which can upload/download a file.
aozarov commentedon Mar 7, 2016
We will fix it soon. How big is your
Blob? Can you apply one of thecreatemethods that takes the blob content in the meantime?sudison commentedon Mar 7, 2016
Ok, thanks. Blob is around 1 - 20 MB. Is create method ok for such blob?
aozarov commentedon Mar 7, 2016
20MB is on the bigger side but Yes, and you can use the
createthat acceptsInputStreamif you don't have the content in memory.sudison commentedon Mar 7, 2016
ok, thanks. then I'll use create for now.
19 remaining items
chore(main): release 2.1.8 (#738)
chore: fix link to documentation (#720)
feat: Add destination property into LogEntry (#720)
chore(deps): update dependency com.google.cloud:libraries-bom to v25 (#…
chore(deps): update dependency com.google.appengine:appengine to v1.9…
feat: Add destination property into LogEntry (googleapis#720)
chore(deps): update dependency com.google.appengine:appengine to v1.9…
fix(java): replace excludedGroup with exclude (googleapis#720)
chore(main): release 2.5.9 (googleapis#721)
deps: update dependency com.google.guava:guava to v31 (#720)
chore: release 0.123.14 (#728)
deps: update dependency com.google.guava:guava to v31 (#720)
chore: release 0.123.14 (#728)
chore: minimize noise from build scripts (#720)
chore: minimize noise from build scripts (#720)