Skip to content

Add bandwidth limit to file download and upload functions #1419

@flip-dots

Description

@flip-dots

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions