-
Notifications
You must be signed in to change notification settings - Fork 739
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
Example demonstrating how to resume an upload #45
Comments
(idea suggested by @jochenkirstaetter) |
Is there a specific language you'd like the example in? I think we should just support this via the python SDK directly |
Just the standard stuff we use here - Python and maybe REST. We need the SDK support too but depending on the complexity we should either update the existing guides here to show resumption or add new ones. |
Hi there, thanks @markmcd to bring this up, appreciated. Any language would be great. And as we are talking about resume. How about parallel upload channel/streams? Is this something possible on the API side? |
Hi @jochenkirstaetter, I don't think we'll have examples or SDK support for .NET. But to unblock you, I think you can rely on the googleapiclient library for .NET and create a DiscoveryService using our API documentation. Then upload files using ResumableUpload class (similar to the Drive example). This is how we're doing it in JS right now until we have SDK Support:
|
Hi @TYMichaelChen Maybe it could be of interest to you that I implemented a client for the Gemini API in NET supporting Google AI and Vertex AI in one package. https://github.com/mscraftsman/generative-ai Actually, the repository contains three projects
This is based on the REST API and a little bit of network capture to correct my initial file upload from the (for me) insufficient sample.sh using multiple requests to the correct use of the multipart request as done in the Python (create_file method) and Javascript SDK. Something I exchanged with @markmcd recently. I also had a look at the official dotnet-docs-samples repository provided by Google. Which is totally different to anything else you provide in the other SDKs. Which is actually the reason I implemented the client in NET. End of February there was nothing available for Gemini, only PaLM 2. Anyway, I'll have a look at the Drive sources, maybe I'll be able to find something. 🤔 FYI, I have a signed CLA and I'm a GDE for Cloud. I'd be glad to assist with an official Gemini SDK for NET. 🙏 |
Hi @TYMichaelChen and @markmcd I think that I found the right information here: https://cloud.google.com/storage/docs/performing-resumable-uploads Those cURL examples are easy to understand. Using the suggested ResumableUpload class should allow me to give it a shot and see what happens. 🙏 |
Hi @MarkDaoust Thanks for following up. // other code before
var multipartContent = new MultipartContent("related");
multipartContent.Add(new StringContent(json, Encoding.UTF8, Constants.MediaType));
multipartContent.Add(new StreamContent(new FileStream(uri, FileMode.Open), (int)Constants.ChunkSize)
// other code after Which already works nice and stable. |
File uploads are resumable, but we don't have any examples of how that works.
When we know the precise chunks already, it's pretty easy, but the example should demonstrate how to recover from an error - e.g. what info to save and how to resume from whatever is there, specifying the right offset.
The text was updated successfully, but these errors were encountered: