Skip to content
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

Add bandwidth limit to file download and upload functions #1419

Open
flip-dots opened this issue Apr 5, 2024 · 1 comment
Open

Add bandwidth limit to file download and upload functions #1419

flip-dots opened this issue Apr 5, 2024 · 1 comment

Comments

@flip-dots
Copy link

What:

The Nextcloud Android client does not currently feature any way to limit bandwidth of the auto upload feature like the desktop client does. To add this feature this library would need to offer an API to limit the download and upload speed.

Why:

A client side limit is useful for cases where network bandwidth is limited and where the router the client is using is not smart enough to throttle invididual devices and insteads results in the entire network hanging (don't ask me how I know :P).

How:

I made a prototype to check the feasability of this by replacing the buffered input and output streams in DownloadFileRemoteOperation and FileRequestEntity with sources and sinks from okio which is a part of okhttp which is already included in the dependancies and then using a Throttler also from okio to then limit bandwidth. I ran some basic tests by uploading and downloading files using the sample client and on my setup upload and download speeds were within 5% of the original speed.

Alternativley an easier approach may be to just insert a delay in the buffer loops but that feels a little hacky to me compared to using okio.

@joshtrichards joshtrichards changed the title Feature Request: Add bandwidth limit to file download and upload functions. Add bandwidth limit to file download and upload functions Jan 31, 2025
@joshtrichards
Copy link
Member

Hi @flip-dots - Sorry for the delay. Can you send in your code as a PR so it can be more formally evaluated by the devs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants