tmenier / Flurl

Fluent URL builder and testable HTTP client for .NET
https://flurl.dev
MIT License
4.23k stars 387 forks source link

How can I speed limit when upload file #812

Closed handloong closed 8 months ago

handloong commented 9 months ago

Flurl.Http : 4.0.2 Flurl : 4.0.2

I'm writing a utility that will be uploading files, and would like to provide the option to rate limit uploads. like max speed : 10M/s Has anyone implemented something like this before?

private async void button1_Click(object sender, EventArgs e)
{

    var speed = 1024 * 1024;// 1M/s

    var fileStream = new FileStream(@"Large File", FileMode.Open);
    var response = await @"http://xxxxx:8000/upload"
        .PostMultipartAsync(content => content
        .AddFile("file", fileStream, "myfile.ios"))
        .ReceiveString();

    MessageBox.Show(response);
}
tmenier commented 8 months ago

Sounds like a programming question, I prefer people use Stack Overflow for that - more visibility and better odds of getting a good answer. I'd even start by searching on it, and frame it as an HttpClient question. I don't actually know the answer, never done anything like that.