cordova - asp.net web api file upload without saving -


ok, writing service recieve file uploads iphone application through phonegap. send me file , trying grab actual file without saving type of file system. have

[httppost] public string processrequest() {     string ext = "entered";     request.content.readasmultipartasync<multipartmemorystreamprovider>(new multipartmemorystreamprovider()).continuewith((tsk) =>     {         ext = "request";         multipartmemorystreamprovider prvdr = tsk.result;          foreach (httpcontent ctnt in prvdr.contents)         {             ext = "foreach";             // hold of inner memory stream here             stream stream = ctnt.readasstreamasync().result;             if (stream == null)             {                 ext = "null stream";             }             image img = image.fromstream(stream);             if (imageformat.jpeg.equals(img.rawformat))             {                 ext = "jpeg";             }             else if (imageformat.png.equals(img.rawformat))             {                 ext = "png";             }             else if (imageformat.gif.equals(img.rawformat))             {                 ext = "gif";             }             // witht stream         }     });     return ext; } 

i have put various responses in there can see function getting to. right returns "entered" means not reading content of request, end game me grab file object, convert image , base 64. direction appreciated. remember want without file system no solutions involve mapping path server folder.

ok little update, have edited code according first response , @ least attempts execute gets infinitely stuck inside code. happens during readasmultipartasync function

[httppost] public string processrequest() {     string ext = "entered";     request.content.readasmultipartasync(new multipartmemorystreamprovider()).continuewith((tsk) =>     {         ext = "request";         multipartmemorystreamprovider prvdr = tsk.result;          foreach (httpcontent ctnt in prvdr.contents)         {             ext = "foreach";             // hold of inner memory stream here             stream stream = ctnt.readasstreamasync().result;             if (stream == null)             {                 ext = "null stream";             }             image img = image.fromstream(stream);             if (imageformat.jpeg.equals(img.rawformat))             {                 ext = "jpeg";             }             else if (imageformat.png.equals(img.rawformat))             {                 ext = "png";             }             else if (imageformat.gif.equals(img.rawformat))             {                 ext = "gif";             }             // witht stream         }     }).wait();     return ext; } 

the block inside continuewith runs asynchronously (if @ signature continuewith, you'll see returns task well). so, above code, you're returning before of has chance execute.

try doing:

request.content.readasmultipartasync().continuewith(...).wait(); 

also, not sure need go trouble of doing request.content.readasmultipartasync<multipartmemorystreamprovider>(new multipartmemorystreamprovider()); believe request.content.readasmultipartasync() should suffice.

hope helps!


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -