This project is read-only.

Download progress

Nov 16, 2010 at 4:11 AM

Hi,

 

Thanks for this excellent library.

 

My question:

Is there a way to inform the user how many bytes are being downloading, for the purpose of showing on the user interface ? If yes, how ?

 

Thanks

Alfonso Moreno

Nov 16, 2010 at 10:44 PM

Hi,

currently we do not support his out of the box but I created an issue with the number 14706 which is assigned to 1.0.3
You can also work with the oAuthManager in the oAuth lib. This singleton is used also for other tracking stuff.

regards
Dirk

Nov 17, 2010 at 4:28 AM

Thank you for your quick answer.

 

I checked issue 14706 and I think it will be preferred if you return the total length in byte of the file that is being download/uploading and the current number of bytes downloaded/uploaded.

 

I think this kind of information is very needed for the end user when when dealing with very big file. At this moment, I have tested with 50 MB files approx, but planned to download/upload 400 MB files.

 

I tracked your code and I think (if I am not wrong) that the delegate or event could be implemented in the following method execution chain:

 

class : DropBoxFileStream

 

        private void DownloadData()
        {
            Stream data = _session.RequestRessourceStreamByUrl(_url + "/" + EncodingHelper.UTF8Encode(_file));
            StreamHelper.CopyStreamData(data, this);

            if (Length > 0 && CanSeek)
                Position = 0;
        }

 

StreamHelper class: Next, following CopyStreamData will be the final implementation:

 

        public static void CopyStreamData(Stream src, Stream trg)
        {
            // validate parameter
            if (src == null || trg == null)
                return;

            if (src.CanRead == false || trg.CanWrite == false)
                return;

            // build the buffer as configured
            byte[] buffer = new byte[_BufferSize];

            // copy the stream data
            int readBytes = 0;

            do
            {
                readBytes = src.Read(buffer, 0, _BufferSize);
                if (readBytes > 0)
                    trg.Write(buffer, 0, readBytes);                
            } while (readBytes > 0);            
        }

Thank you

Nov 17, 2010 at 9:03 PM

Hi,

yes you are totally right

Dirk