On Thu, Jan 19, 2012 at 11:10 AM, Gonzalo Paniagua Javier
<[email protected]> wrote:
> On Thu, Jan 19, 2012 at 10:57 AM, subsembly <[email protected]> wrote:
>> It's not a feature request. It's a SEVERE BUG in the Mono WebClient
>> implementation!
>
> Ok. Since the world is going to end, I will take a look just to make
> sure that it is just a common bug and can be fixed quickly ;-).

Turns out the world is not going to end today. This is not a bug.

The following program:
---------------

using System;
using System.Net;
using System.Threading;

class Test {
        static void Main ()
        {
                ManualResetEvent evt = new ManualResetEvent (false);
                WebClient wc = new WebClient ();
                wc.UploadFileCompleted +=  new UploadFileCompletedEventHandler 
(CB);
                wc.UploadFileAsync (new Uri ("http://127.0.0.1:9000/";), "POST",
"uploadfile.cs", evt);
                evt.WaitOne ();
        }

        static void CB (object sender, UploadFileCompletedEventArgs e)
        {
                if (!e.Cancelled && e.Error == null) {
                        Console.WriteLine ("File uploaded");
                } else {
                        Console.WriteLine ("Something went wrong");
                        Console.WriteLine (e.Error);
                }
                ((ManualResetEvent) e.UserState).Set ();

        }
}
--------------

when run under MS.NET has this at the beginning of the body:
 -----------------------8cea4b4aff65c6b
 Content-Disposition: form-data; name="file"; filename="uploadfile.cs"
 Content-Type: application/octet-stream

The same program run using Mono yields:
--------------8cea4b552ea3188
Content-Disposition: form-data; name="file"; filename="uploadfile.cs"
Content-Type: application/octet-stream

Perhaps what you want is more like:
   file.ReadAllBytes ("yourfile");
   wc.UploadData (...).


Cheers.

-Gonzalo
_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to