0
votes

i'm not sure if the title is understandable or not. But all i want to ask is, i want to upload a jpeg file from my WindowsPhone 8 client app. to a WCF web service. But i dont want direct upload, i want to handle the stream.So i wrote a script for reading image. Here it is:`

       byte[] buffer = new byte[32*1024];
        int read;   
        using (MemoryStream ms=new MemoryStream())
        {
            while ((read = Fs.Read(buffer, 0, buffer.Length)) > 0)
            {
                ms.Write(buffer, 0, read);
            }
        }`

Fs is myImage's reader.( FileStream Fs = new FileStream("FİLE", FileMode.Open, FileAccess.Read); ) For now everthing seems ok. But while i'm reading the image file i want to upload byte array of it. And server-side Wcf service will join the array and after joining i'll push it to my Azure Storage account(blob). You can say: You dont need to this. Use Phone.Storage and push it to your blob. But i want to show progressing level of uploading.

ms.Write(buffer, 0, read);

after this , Wcf method have to work but how? How can i handle this situation? if it is possible and want to write this Wcf with async methods.

Thanks for your answers and sorry about my bad expression.

1
Can you share some code for the WCF server-side handler?Jedidja
the problem is i didn't write any codes for WCF i'm asking for it. if its possible i want to write it with async methods.afrikaan
You probably want to create a separate question asking how to write a WCF service (that be accessed from a windows phone app) that will support async, streaming file upload. And also perhaps mention that you want to host this WCF service on Azure.Jedidja
yes indeed.i want to host it my Azure account,i know how to write a Wcf but i dont know handling streaming upload,just i mentioned.afrikaan
Is there a particular reason why you want to have this kind of architecture? If the final destination of your image file is blob storage, you could directly upload into blob storage from your Windows Phone device.Gaurav Mantri

1 Answers

0
votes

Well, here's a sample about the WCF part. Let me know if you need something else.

<system.serviceModel>
     …
    <bindings>
      <basicHttpBinding>
        <binding name="ExampleBinding" transferMode="Streaming"/>
      </basicHttpBinding>
    </bindings>
     …
<system.serviceModel>





[ServiceContract]
public interface IStreamedService
{
    [OperationContract]
    void Upload(Stream data);
}