I’m working on a C# desktop application and need to fetch multiple documents from Google Drive. Right now I’m downloading them one by one which takes forever when there are many files.
Is there a way to tell the Google Drive API to compress multiple documents into a single archive before sending them to my application? This would really help with download speed.
I’m also wondering about the best approach for downloading - should I create multiple background workers to grab files at the same time, or is it better to just download everything one after another in a single loop?
Any suggestions on making this process faster would be great. The files are mostly text documents and spreadsheets if that matters.
u nailed it! Google Drive API doesn’t zip files for ya. just grab them one by one then use something like System.IO.Compression to zip after. using Task.Run() for parallel downloads really boosts speed! give it a shot!
I’ve built similar apps and the Drive API doesn’t have built-in compression, but here’s what worked for me. I set up parallel downloads with CancellationTokens for timeout handling. The trick is batching 3-5 files at a time instead of going full parallel - keeps you under Google’s rate limits while still getting decent performance gains. For compression, I went with SharpZipLib over the built-in stuff since it handles mixed file types way better (docs, spreadsheets, etc.). Watch your memory usage on bigger files though - stream directly to your zip instead of loading everything first. And definitely add retry logic because network hiccups will happen with concurrent downloads.
Unfortunately, Google Drive API doesn’t support server-side compression for multiple files. You’ll have to download each file individually and compress them yourself. But you can speed things up a lot with parallel downloads instead of doing them one by one. I’ve had good luck using HttpClient with async/await for this. Set up a semaphore to limit concurrent connections - usually 5-10 downloads at once works well without hitting API rate limits. Once you’ve got all the files downloaded to memory or temp storage, just use .NET’s built-in compression libraries to create your archive. Just watch Google’s API quotas when doing parallel downloads - too many requests at once will get you rate limited.
This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.