public async Task Upload(ResumableUploadDetails resumableUpload)
        {
            UploadResponse uploadInfo = null;
            for (int i = 0; i < resumableUpload.NumberOfUnits; i++)
            {
                Console.WriteLine("##############  Uploading unit {0}  ##############", i);
                uploadInfo = await UploadUnit(i, resumableUpload);

                Console.WriteLine("\n\n");

            }


            int chunk = 0;
            foreach (short word in uploadInfo.ResumableUpload.Bitmap.Words)
            {
                for (int j = 0; j < 16 && chunk < uploadInfo.ResumableUpload.NumberOfUnits; j++, chunk++)
                {
                    if ((word & 0x1) != 1)
                        Console.WriteLine("Chunk {0}, failed to upload", chunk);
                }
            }

            if (uploadInfo.ResumableUpload.AllUnitsReady == false)
            {
                Console.WriteLine("Some chunks weren't uploaded.");
                return;
            }

            do
            {
                var uploadDetails = await _agent.Upload.PollUpload(uploadInfo.DoUpload.Key);

                if (uploadDetails.IsComplete)
                {
                    Console.WriteLine("File quick key is {0}", uploadDetails.QuickKey);
                    return;
                }
            } while (true);

        }
        private async Task<UploadResponse> UploadUnit(int unit, ResumableUploadDetails resumableUpload)
        {

            var block = new byte[resumableUpload.UnitSize];
            var unitSize = _fileStream.Read(block, 0, block.Length);
            var unitHash = GetBlockHash(block, unitSize);

            var headers = new Dictionary<string, string>
            {
                {MediaFireApiConstants.ContentTypeHeader, MediaFireApiConstants.ResumableUploadContentTypeValue } ,
                {MediaFireApiConstants.FileNameHeader, FileName } ,
                {MediaFireApiConstants.FileSizeHeader, FileLength.ToString() } ,
                {MediaFireApiConstants.FileHashHeader, FileHash } ,

                {MediaFireApiConstants.UnitHashHeader, unitHash } ,
                {MediaFireApiConstants.UnitIdHeader, unit.ToString() } ,
                {MediaFireApiConstants.UnitSizeHeader, unitSize.ToString() } ,
            };


            var parameters = new Dictionary<string, object>
            {
                //{MediaFireApiParameters.QuickKey, ""}      ,
                //{MediaFireApiParameters.ActionOnDuplicate, MediaFireActionOnDuplicate.Replace}               ,
                //{MediaFireApiParameters.FolderKey, ""}      ,
                ///etc
            };

            var contentToUpload = new MemoryStream(block, 0, unitSize);



            return (await _agent.PostStreamAsync<UploadResponse>(MediaFireApiUploadMethods.Resumable, contentToUpload, parameters, headers, progress:new Progress<MediaFireOperationProgress>(
                (s) =>
                {
                    Console.Write(".");
                })));


        }