-
Notifications
You must be signed in to change notification settings - Fork 550
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
WIP: Add streaming uploads. #8235
Conversation
@simi Thank you so much for this suggestion! I really like how you use I see two alternatives for adding your code to the library:
For the latter, I'd like to get input from some other stakeholders. @dazuma, @frankyn: Any thoughts on this? |
@quartzmo Yes, I have seen following in ruby api client README.md
and decided to not contribute in there since it is not easy to change code in three. If I understand it well, that code is somehow generated and it is probably not easy to contribute changes anyway.
My code works standalone, that's true. Looking at aws/aws-sdk-ruby#1711 it should be possible to actually create upload stream class to be able to use # using API
storage = Google::Cloud::Storage.new
bucket = storage.bucket 'rasa-as-test'
file = bucket.file('my_file', skip_lookup: true)
signed_url = file.signed_url(method: :POST, headers: {'x-goog-resumable' => 'start'}, version: :v4)
read_stream = StringIO.new('ABC')
# using utility class, just bring your own signed url able to do resumable upload
uploader = Google::Cloud::Storage::ChunkedUploadStream.new(signed_url, content_type: nil, chunk_size: 1024 * 1024)
uploader.upload do |write_stream|
IO.copy_stream(read_stream, write_stream)
end
Regarding Faraday, it is already in-direct dependency of google-cloud-storage (
I think any of those solutions should be part of this SDK since I would like to contribute this possibility more upstream (for example to Rails' ActiveJob) to make it possible to be used easily by users of those libraries and vendoring this kind of code is not usually welcomed (same as using additional 3rd party gem to handle stuff not supported by official SDK). Contributing general utility class like mentioned |
@simi Personally I like your suggestion a lot. I'll try to get some other maintainers to take a look, so please hold on for now. |
I like the idea of a separate utility class to handle the upload. As long as it is separable from the storage classes, so it's easy to lift out and contribute upstream if necessary. |
Synced with @quartzmo about this FR. He's going to work it into google-api-client resumable upload logic. We found that it is possible but requires introducing chunking into the upload to handle streams. We should not merge this PR and instead use it as an example. Thanks @simi for proposing this PR! |
@simi I'm going to close this PR. Thank you so much for prompting a new effort to support streaming uploads in this client stack! |
Hello, any news on this? I can't find anything related in |
@quartzmo pingie. |
As commented on googleapis/google-api-ruby-client#759, this is still blocked as far as I know by googleapis/google-api-ruby-client#2348. |
The code in this PR should still be regarded as a proposed usage sample for the google-cloud-storage library, but not added as a library feature. |
Hello.
This is my initial take on proposed new method to be able to upload IO in chunks. It works for any IO-like object supporting
eof?
,pos
andread(bytes)
methods.I'm opening this PR to find out interest to making this part of official SDK. There is still some work left. I left some TODOs as well. Tests and docs are missing for now, but I'm ready to spend more time on this.
Simple example:
It is also possible to wrap IO object to build more complex stuff like progress bar and calculate md5 and crc32c on the fly to compare.