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
feat: add storage.upload(path) #269
Merged
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
6af9ce2
feat: add storage.upload(path)
dmitry-fa 085739f
feat: use mockito framework
dmitry-fa 83ad702
feat: update upload to return blob
dmitry-fa 94d2948
feat: do not parse response from writers for signed urls
dmitry-fa e59bece
Merge branch 'master' into storageUpload3
dmitry-fa 0806031
Merge branch 'master' into storageUpload3
dmitry-fa 67a701e
fix reviewer's comments
dmitry-fa 41f1875
Merge branch 'master' into storageUpload3
dmitry-fa d62e615
Update Storage.upload() functionality after merge
dmitry-fa d55513f
feat: deprecate StorageRpc.write(), introduce StorageRpc.upload()
dmitry-fa 773d587
feat: deprecate StorageRpc.write(), introduce StorageRpc.upload()
dmitry-fa 0d9b17f
Merge branch 'master' into storageUpload3
dmitry-fa 3c9f2dc
Merge branch 'storageUpload3_next' into storageUpload3
dmitry-fa d7c7f1b
rename upload to createFrom
dmitry-fa File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- see http://www.mojohaus.org/clirr-maven-plugin/examples/ignored-differences.html --> | ||
<differences> | ||
<difference> | ||
<differenceType>7012</differenceType> | ||
<className>com/google/cloud/storage/Storage</className> | ||
<method>void upload(*.BlobInfo, java.nio.file.Path, *.Storage$BlobWriteOption[])</method> | ||
</difference> | ||
<difference> | ||
<differenceType>7012</differenceType> | ||
<className>com/google/cloud/storage/Storage</className> | ||
<method>void upload(*.BlobInfo, java.io.InputStream, *.Storage$BlobWriteOption[])</method> | ||
</difference> | ||
</differences> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blob should be returned from upload() methods similar to create() methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
returning Blob requires an extra RPC request to be issued, that is not always needed.
I can add uploadFrom() method to the Blob class (symmetric to downloadTo) to return an updated Blob.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A month ago I compared upload/download implemented in various ways for several types of file. This is the summary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dmitry-fa,
I was thinking about the issue you filed: #149
When the upload is complete GCS responds with object metadata so we don't need to perform an additional get request. flushBuffer doesn't return a value so we'd diverge from the spec a bit to get the metadata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean we can update the StorageRpc interface to make
void write(uploadId, ...)
to return a StorageObject?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a nit at all :) It's a significant change. I agree with you, upload() should return Blob.
I see the following ways how to implement:
Update the StorageRpc interface and make write() to return a StorageObject instance or null in write is not final request for the given upload. Now StorageRpc .write() returns null.
Update HttpStorageRpc.write() to remember StorageObject and return this object in a separate method.
In this case BlobWriterChannel.fluchBuffer() will look like:
I believe 2. is not a Google way, so we should go 1. As a temporary solution 3. is also considered, because it could be improved to 1.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @frankyn,
I managed to implement upload based on your hint. I modified
StorageRpc.write()
to returnStorageObject
instead ofvoid
.Two issues were found:
GCS does not respond with object metadata if writer was created by
storage.writer(signedUrl)
Not sure if it's a bug or a feature, looks like a bug: spec says nothing about it. I worked it around.
Change StrorageRpc affects storage-nio, Kokoro - Test: Linkage Monitor fails:
(com.google.cloud:google-cloud-nio:0.120.0-alpha) com.google.cloud.storage.contrib.nio.testing.FakeStorageRpc's method write(String arg1, byte[] arg2, int arg3, long arg4, int arg6, boolean arg7) is not implemented in the class referenced from com.google.cloud.storage.spi.v1.StorageRpc (com.google.cloud:google-cloud-storage:1.107.1-SNAPSHOT)
cc: @JesseLovelace