-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
api: storageIssues related to the Cloud Storage API.Issues related to the Cloud Storage API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.
Description
All documentation points to the following being the best practice for uploading a large file
String bucketName = "my_unique_bucket";
String blobName = "my_blob_name";
BlobId blobId = BlobId.of(bucketName, blobName);
InputStream inputStream = new FileInputStream(new File("largefile.zip"));
BlobInfo blobInfo = BlobInfo.builder(blobId).contentType("application/octet-stream").build();
try (WriteChannel writer = storage.writer(blobInfo)) {
try {
while ((limit = inputStream.read(buffer)) >= 0) {
writer.write(ByteBuffer.wrap(buffer, 0, limit));
}
} catch (Exception ex) {
// handle exception
}
}The question is how do we fail an upload if an exception is thrown midway?
Metadata
Metadata
Assignees
Labels
api: storageIssues related to the Cloud Storage API.Issues related to the Cloud Storage API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.