Sending a file over HTTP?

Just wondering how I will send the file over HTTP. I am using HTTPRequest. The data should be output in binary form, so I can send it on a multidisciplinary request. And ideas on how I do this? I am completely lost.

+3
source share
1 answer

If you just need a file sent as the body of POST / STOR / etc, then WebClientit will simplify:

    using (WebClient client = new WebClient())
    {
        client.UploadFile(address, fileName);

        // or to specify a custom method:
        client.UploadFile(address, "PUT", fileName);
    }

If you need a form, it's harder; you will need multipart-mime, which is not directly supported; You will have to write it or use existing code from the network.

+3
source

Source: https://habr.com/ru/post/1733706/


All Articles