Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

can anybody please tell me how can i create a WCF Rest service through which i can be abel to upload files to server using android , iphone & WP7.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
398 views
Welcome To Ask or Share your Answers For Others

1 Answer

Thanks for help I was able to create file upload wcf rest service for multiple platform.

public void FileUpload(string fileName, Stream fileStream)
{
    FileStream fileToupload = new FileStream("c:\FileUpload" + fileName, FileMode.Create);

    byte[] bytearray = new byte[10000];
    int bytesRead, totalBytesRead = 0;
    do
    {
        bytesRead = fileStream.Read(bytearray, 0, bytearray.Length);
        totalBytesRead += bytesRead;
    } while (bytesRead > 0);

    fileToupload.Write(bytearray, 0, bytearray.Length);
    fileToupload.Close();
    fileToupload.Dispose();
}

[ServiceContract]
public interface IImageUpload
{
    [OperationContract]
    [WebInvoke(Method = "POST", UriTemplate = "FileUpload/{fileName}")]
    void FileUpload(string fileName, Stream fileStream); 
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...