7

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.

1 Answer 1

15

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)

Sign up to request clarification or add additional context in comments.

5 Comments

Is it also possible to get callbacks to monitor the progress of the upload?
Oh just noticed it has the callbacks for monitoring progress :-) Thanks a lot!
@sharjeel: hey, can u post a snippet how to do callbacks for monitoring progress using WebClient
@FosterZ, use UploadFileAsync method and use the UploadProgressChanged delete. Take a look at this link: stackoverflow.com/questions/982299/webclient-uploadfile/…
don't forget to call Dispose (or use a Using)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.