protected override void Build(IHttpStreamable httpStream, bool prepare) { if (prepare) { return; } using (FileStream fis = new FileStream(fileLink.Path, FileMode.Open)) { int bytesRead = -1; byte[] buffer = new byte[HttpConfig.ChunkSize]; while ((bytesRead = fis.Read(buffer, bytesRead, buffer.Length)) != -1) { httpStream.WriteUnderlying(buffer, 0, bytesRead); } httpStream.FlushUnderlying(); } }
private void WriteFile(IHttpStreamable httpStream, FileLink fileLink) { if (Chunked) { ChunkHandler.WriteChunk(httpStream); httpStream.FlushUnderlying(); if (ChunkHandler.IsFinished) { ChunkHandler.Dispose(); } return; } using (FileStream fis = new FileStream(fileLink.Path, FileMode.Open)) { int bytesRead = -1; byte[] buffer = new byte[HttpConfig.ChunkSize]; while ((bytesRead = fis.Read(buffer)) != -1) { httpStream.WriteUnderlying(buffer, 0, bytesRead); } httpStream.FlushUnderlying(); } }