1

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.

1
  • if possible please provide working example or resource. i am new to wcf. Commented Jun 11, 2012 at 13:30

2 Answers 2

4

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); 
}
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for this.. can you please post the android code that you used to upload an image to this code?
could you tell me the way to access this service from android device
2

Any Rest service can be accessed using Android, iphone and WP7.

One option is to create a Rest POST service using WCF or MVC and get the image in data as base64 string.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.