sharjeel
sharjeel

Reputation: 6005

File upload HTTP PUT in C#

I am writing a desktop app in C# for upload large sized files on a webserver using HTTP PUT. I have tried libcurl .net but it seems the bindings seem pretty difficult to use.

Is there a better and easier way?

PS: My server is nginx. I believe HTTP PUT is the best way but if there is a better alternative available on nginx, I can use that as well.

Upvotes: 7

Views: 11873

Answers (1)

Dean Harding
Dean Harding

Reputation: 72658

Have you tried the built-in WebClient, doesn't get much simpler:

var wc = new WebClient();
wc.UploadData("http://www.example.com/upload-image", "PUT", imageData);

(WebClient.UploadFile is also available, which might be even better, depending on where your image data is located)

Upvotes: 15

Related Questions