Exemplo n.º 1
0
        void SendNextChunk()
        {
            _RetryCount++;
            byte[] buffer = new byte[Utility.chunkSize];

            if (this.FilePosition != _FileStream.Position)
            {
                _FileStream.Seek(this.FilePosition, SeekOrigin.Begin);
            }

            _CurrentWriteLength = _FileStream.Read(buffer, 0, Utility.chunkSize);

            if (_CurrentWriteLength != Utility.chunkSize && _CurrentWriteLength > 0)
            {
                //resize buffer  to read size.
                byte[] new_buffer = new byte[_CurrentWriteLength];
                for (int ix = 0; ix < _CurrentWriteLength; ix++)
                {
                    new_buffer[ix] = buffer[ix];
                }
                buffer = null;
                buffer = new_buffer;
            }

            ChunkUploadRequest chunk_request = new ChunkUploadRequest();

            chunk_request.Chunk = buffer;
            chunk_request.Hash  = Utility.GetSHA256Hash(buffer);
            chunk_request.Token = this.Token;
            _Message            = Utility.SerializeXml(chunk_request);

            BeginSendRequest();
        }
Exemplo n.º 2
0
		void SendNextChunk()
		{
			_RetryCount++;
			byte[] buffer = new byte[Utility.chunkSize];

			if (this.FilePosition != _FileStream.Position)
				_FileStream.Seek(this.FilePosition, SeekOrigin.Begin);

			_CurrentWriteLength = _FileStream.Read(buffer, 0, Utility.chunkSize);

			if (_CurrentWriteLength != Utility.chunkSize && _CurrentWriteLength > 0)
			{
				//resize buffer  to read size. 
				byte[] new_buffer = new byte[_CurrentWriteLength];
				for (int ix = 0; ix < _CurrentWriteLength; ix++)
				{
					new_buffer[ix] = buffer[ix];
				}
				buffer = null;
				buffer = new_buffer;
			}

			ChunkUploadRequest chunk_request = new ChunkUploadRequest();
			chunk_request.Chunk = buffer;
			chunk_request.Hash = Utility.GetSHA256Hash(buffer);
			chunk_request.Token = this.Token;
			_Message = Utility.SerializeXml(chunk_request);

			BeginSendRequest();
		}