Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7848215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:07:25+00:00 2026-06-02T18:07:25+00:00

I have successfully made an app that sends a request from my Windows Phone

  • 0

I have successfully made an app that sends a request from my Windows Phone to a WCF api hosted in an azure web role. I am using a restful POST method to do this using RestSharp. It all works brilliantly and the images are appearing in storage but the images are not opening as normal image files.

Comparing them to other images I uploaded previously, in the metadata info it says the unviewable images have a contentMD5 field which is set to something like “AKEYWqGgulwi6/9/VY2KPg==” (whereas the others do not) could this be what is causing the problem with the files?

I have attached my RestSharp code, maybe I’m am adding something I shouldn’t be? The error I suspect must be coming from here as this is the only place where the imagestream is manipulated.

   public void SendRequest(Stream imageStream, string imageID)
    {
        var client = new RestClient();
        client.BaseUrl = apiAddress;
        var request = new RestRequest("agerecog/{imageName}", Method.POST);
        request.AddUrlSegment("imageName", imageID);

        //convert imagestream to byte array
        var byteArray = new byte[imageStream.Length];
        imageStream.Read(byteArray, 0, (int)imageStream.Length);

        //add byteArray to request
        request.AddFile("image/jpeg", byteArray, imageID);
        var url = client.BuildUri(request).ToString();
        client.ExecuteAsync<VizageResponse>(request, response =>
            {
                //request info. to be added here
            });
    }

EDIT #1
After some work I decided to change the addFile line to this:

  request.AddFile(null, byteArray, null);

Which changed the stream length and also made the contentMD5 field empty. However, the image is still not a valid image file. Given the fact the images I am comparing are both from the Windows Phone emulator they should both be an identical white page with a small black square in the corner – but there is a different in size between the file (5670 length for the valid image file, 6076 length for the original code and 6239 length using the second addFile above)

EDIT #2
Doing some more analysis, when the before the image Stream is sent its length property is 6116, when it arrives on the server, however it is 6370. 264 is being added from somewhere in the RestSharp method I believe or when the stream of data is interpreted on the server side. The code of the WCF service:

  [WebInvoke(UriTemplate = "/agerecog/{imageName}", Method = "POST")]
    VizageResult analyseFace(string imageName, Stream imageStream);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:07:27+00:00Added an answer on June 2, 2026 at 6:07 pm

    Problem Solved

    I have finally solved the problem and an image is visible as the end result. What was happening was that the imageStream also contained data regarding the name of the file and this was causing it (when saved in Azure) to not appear as an image file.

    I fixed this by using the MultipartParser class found here: http://multipartparser.codeplex.com/ on the server side to parse the request into the filename and filestream chunks. I then saved the image from this byte[] using the normal process.

    My code to parse the webrequest data into its constituent parts is found below:

        MemoryStream imageStream = new MemoryStream();
    
         MultipartParser parser = new MultipartParser(dataStream);
            if (parser != null && parser.Success)
            {
                imageName = parser.Filename;
                imageStream.Write(parser.FileContents, 0, parser.FileContents.Length);
            }
    

    When you use the memory stream remember to set its position back to 0 – a schoolboy mistake I made!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some trouble regarding a rest request sent from my Windows Phone app
I have an app that streams video from the net and plays it using
I have an iPhone app that is using CoreData. I recently made some minor
I have installed my enterprise iPad App using itunes successfully. When I have made
I'm using Pex and Moles 0.94.51023.0 with VS2010 SP1. I have successfully made some
i have made my custom Static Library (.a) successfully. i have tested it in
I have an iphone app that uses Core Data to do storage. I have
I have a web application which uses membership and profiles. I successfully used the
I have successfully made contact with the internet and parsed a few documents via
I have my first Windows Mobile app ready for deployment (Windows Mobile 6). I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.