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 8969399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:35:08+00:00 2026-06-15T17:35:08+00:00

I am working on a mobile app for Android and iPhone that uses ServiceStack,

  • 0

I am working on a mobile app for Android and iPhone that uses ServiceStack, Mono For Android, and MonoTouch. Part of the app allows users to upload files to our server, which I am currently doing via the ‘JsonServiceClient.PostFileWithRequest(string relativeOrAbsoluteUrl, Stream fileToUpload, string fileName, object request)’ method. This is working fine, however I would like to show a progress bar indicating data sent.

For my first attempt at this I created a class that wraps a Stream and periodically raises a ProgressChanged event as data is read out of the stream. Unfortunately this doesn’t work very well as it seems all data is read from the stream before any sending beings (at least for files up to 90Mb that I’ve tested). The effect is the progress bar runs up to 100% quickly and then sits at 100% while the data are actually transmitted to the server. Eventually the PostFileWithRequest() call completes and the file is transfered successfully but the progress bar behaviour is less than ideal.

Does anyone have any suggestions on how I could get progress updates that more accurately represent the file upload progress?

  • 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-15T17:35:08+00:00Added an answer on June 15, 2026 at 5:35 pm

    The solution I’ve come up with to solve this problem is to divide the source stream into chunks and call ‘PostFileWithRequest’ multiple times. I update the progress bar between post calls. There is the added bonus that cancelling and restarting an upload are easy to implement using this approach but I’m sure this can’t be particularly efficient.

    Anyway, in pseudo-code, my solution looks something like this:

    using (var client = new JsonServiceClient(WebServiceAddress))
    {
        var src = GetStreamForFileToSend();
        long totalBytes = src.CanSeek ? src.Length : 0;
        long byteOffset = 0;
    
        byte[] Chunk = new byte[Constants.UploadChunkSize];
        for (int read; (read = src.Read(Chunk, 0, Chunk.Length)) != 0;)
        {
            // Progress update
            UploadProgress(byteOffset, totalBytes);
    
            using (var mem = new MemoryStream(Chunk, 0, read))
            {
                // The request contains a guid so the web service can concatenate chunks
                // from the same client
                var request = new UploadFileData(MyUniqueClientGuid, byteOffset, totalBytes);
    
                // Send the chunk
                UploadFileDataResponse response = client.PostFileWithRequest<UploadFileData>(
                    UploadFileData.Route, mem, filename, request);
    
                // Cancelling supported easily...
                if (response.Cancelled)
                    break;
    
                byteOffset += read;
    
                // Can also use 'src.Seek()' and send only the remainder of the file if the
                // response contains info about how much of the file is already uploaded. 
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're working on a web app that will deployed to mobile devices, iPad, iPhone,
I want to integrate Facebook with my Birthday App, so I started https://developers.facebook.com/docs/mobile/android/build/ working
I am currently working on a mobile app that is going to communicate with
My company is working on a dynamic mobile app that updates the look and
I am working on a mobile app on the Android platform (and going forward
I'm working on mobile (Android/iOS) app, which will integrate with FB and have a
Has anyone successfully created an Extjs app that works on iPhone, iPad and Android?
I'm working on an online multiplayer mobile web app that runs 100% in the
I am working on a mobile app written HTML/CSS/PHP/jQuery, testing on Android (Gingerbread) and
Working on a mobile app that needs to use a public API for accessing

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.