-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Storage - StorageWriter how to fail the entire write of InputStream #1232
Comments
WriteChannel writer = storage.writer(blobInfo);
boolean uploadFailed = false;
try {
while ((limit = inputStream.read(buffer)) >= 0) {
writer.write(ByteBuffer.wrap(buffer, 0, limit));
}
} catch (Exception ex) {
uploadFailed = true;
// handle exception
}
if (!uploadFailed) {
writer.close();
} We might consider adding an |
Thanks! |
What about a GC finalizer that would close the writer if it is not explicitly cancelled? |
@mziccard After som discussions internally we are still not convinced this would fail the upload due to it might get closed + flushed anyway by a finalizer at some later point. Anybody know if the above statement holds true? |
I am not aware of any way to "close/abort" a resumable upload session, without actually finalizing the upload. My understanding is that the resumable upload session will expire after a while, if the upload is not finalized. @Capstan is surely more informed than I am (have to ping you directly as I see you are not yet part of the @GoogleCloudPlatform/cloud-storage team). |
FYI @stephenplusplus |
Edited for a much simpler answer. Use the
|
@fonzy2013 Yes we could implement that but it's not a priority at the moment. Is there a particular use case for deleting a resumable upload session? Regardless of the reason for which a chunk upload failed it seems like a better idea to retry uploading using the resumable session until it expires. Rather than deleting the session and opening a new one. |
@fonzy2013 You'd really only want to delete a session if you somehow are no longer in control the session URL and know you need to abort it, e.g.,
|
The protocol as described by the Google Cloud Storage JSON documentation is essentially the Google Data resumable protocol, aka |
The usecase is that we download assets from another system and uploads them to GCS. The other system which is a build server deletes the assets after a time which can lead to halfuploaded assets to GCS. I'm not entirely sure what is meant by a session in this context as our uploader runs as a service and uploads all the time. |
A bit more information that might be useful: we don't use resumable uploads. |
We should add |
This has been added to our feature backlog: https://github.com/GoogleCloudPlatform/google-cloud-java/wiki/Feature-backlog. This issue will be closed but is linked in the backlog and can continue to be used for comment and discussion. |
🤖 I have created a release *beep* *boop* --- ## [3.4.0](googleapis/java-asset@v3.3.1...v3.4.0) (2022-06-30) ### Features * Enable REST transport for most of Java and Go clients ([googleapis#1242](googleapis/java-asset#1242)) ([86eb248](googleapis/java-asset@86eb248)) ### Bug Fixes * update gapic-generator-java with mock service generation fixes ([googleapis#1249](googleapis/java-asset#1249)) ([7d124ad](googleapis/java-asset@7d124ad)) ### Dependencies * update dependency com.google.api.grpc:proto-google-cloud-orgpolicy-v1 to v2.2.1 ([googleapis#1245](googleapis/java-asset#1245)) ([9b0d4e9](googleapis/java-asset@9b0d4e9)) * update dependency com.google.api.grpc:proto-google-cloud-pubsub-v1 to v1.101.0 ([googleapis#1228](googleapis/java-asset#1228)) ([c5f1712](googleapis/java-asset@c5f1712)) * update dependency com.google.api.grpc:proto-google-cloud-pubsub-v1 to v1.101.1 ([googleapis#1233](googleapis/java-asset#1233)) ([42031ef](googleapis/java-asset@42031ef)) * update dependency com.google.api.grpc:proto-google-identity-accesscontextmanager-v1 to v1.3.1 ([googleapis#1246](googleapis/java-asset#1246)) ([d868803](googleapis/java-asset@d868803)) * update dependency com.google.cloud:google-cloud-bigquery to v2.13.1 ([googleapis#1227](googleapis/java-asset#1227)) ([113c52f](googleapis/java-asset@113c52f)) * update dependency com.google.cloud:google-cloud-bigquery to v2.13.3 ([googleapis#1234](googleapis/java-asset#1234)) ([7006c44](googleapis/java-asset@7006c44)) * update dependency com.google.cloud:google-cloud-bigquery to v2.13.4 ([googleapis#1239](googleapis/java-asset#1239)) ([9c59632](googleapis/java-asset@9c59632)) * update dependency com.google.cloud:google-cloud-bigquery to v2.13.6 ([googleapis#1244](googleapis/java-asset#1244)) ([a305745](googleapis/java-asset@a305745)) * update dependency com.google.cloud:google-cloud-core to v2.8.0 ([googleapis#1238](googleapis/java-asset#1238)) ([8224b02](googleapis/java-asset@8224b02)) * update dependency com.google.cloud:google-cloud-resourcemanager to v1.4.0 ([googleapis#1230](googleapis/java-asset#1230)) ([5655582](googleapis/java-asset@5655582)) * update dependency com.google.cloud:google-cloud-shared-dependencies to v2.13.0 ([googleapis#1241](googleapis/java-asset#1241)) ([2ebe221](googleapis/java-asset@2ebe221)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
…1.1 (#1232) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:libraries-bom](https://cloud.google.com/java/docs/bom) ([source](https://togithub.com/googleapis/java-cloud-bom)) | `26.1.0` -> `26.1.1` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.1/compatibility-slim/26.1.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.1/confidence-slim/26.1.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. ⚠ **Warning**: custom changes will be lost. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-automl). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xODQuMiIsInVwZGF0ZWRJblZlciI6IjMyLjE4NC4yIn0=-->
All documentation points to the following being the best practice for uploading a large file
The question is how do we fail an upload if an exception is thrown midway?
The text was updated successfully, but these errors were encountered: