代码之家  ›  专栏  ›  技术社区  ›  sharjeel

文件上传HTTP放入C#

  •  4
  • sharjeel  · 技术社区  · 14 年前

    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 回复  |  直到 14 年前
        1
  •  13
  •   Dean Harding    14 年前

    你试过内置的吗 WebClient 不会变得更简单:

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

    ( WebClient.UploadFile 也可以使用,这可能更好,具体取决于您的图像数据所在的位置)