File: fix download

This commit is contained in:
pavelbannov 2022-06-22 15:54:43 +03:00
parent 274e89f51c
commit 914c9bc799
3 changed files with 13 additions and 29 deletions

View File

@ -16,7 +16,8 @@
using System.IO; using System.IO;
using System.Text; using System.Text;
using System.Threading.Tasks;
using ASC.Common; using ASC.Common;
using ASC.Files.Core.Resources; using ASC.Files.Core.Resources;
@ -34,12 +35,6 @@ namespace ASC.Web.Files.Core.Compress
private GZipOutputStream gzoStream; private GZipOutputStream gzoStream;
private TarOutputStream gzip; private TarOutputStream gzip;
private TarEntry tarEntry; private TarEntry tarEntry;
private TempStream TempStream { get; }
public CompressToTarGz(TempStream tempStream)
{
TempStream = tempStream;
}
/// <summary></summary> /// <summary></summary>
/// <param name="stream">Accepts a new stream, it will contain an archive upon completion of work</param> /// <param name="stream">Accepts a new stream, it will contain an archive upon completion of work</param>
@ -63,14 +58,10 @@ namespace ASC.Web.Files.Core.Compress
/// Transfer the file itself to the archive /// Transfer the file itself to the archive
/// </summary> /// </summary>
/// <param name="readStream">File data</param> /// <param name="readStream">File data</param>
public void PutStream(Stream readStream) public async Task PutStream(Stream readStream)
{ {
using (var buffered = TempStream.GetBuffered(readStream)) PutNextEntry();
{ await readStream.CopyToAsync(gzip);
tarEntry.Size = buffered.Length;
gzip.PutNextEntry(tarEntry);
buffered.CopyTo(gzip);
}
} }
/// <summary> /// <summary>

View File

@ -15,7 +15,8 @@
*/ */
using System.IO; using System.IO;
using System.Threading.Tasks;
using ASC.Common; using ASC.Common;
using ASC.Files.Core.Resources; using ASC.Files.Core.Resources;
@ -31,12 +32,7 @@ namespace ASC.Web.Files.Core.Compress
{ {
private ZipOutputStream zipStream; private ZipOutputStream zipStream;
private ZipEntry zipEntry; private ZipEntry zipEntry;
private TempStream TempStream { get; }
public CompressToZip(TempStream tempStream)
{
TempStream = tempStream;
}
/// <summary> </summary> /// <summary> </summary>
/// <param name="stream">Accepts a new stream, it will contain an archive upon completion of work</param> /// <param name="stream">Accepts a new stream, it will contain an archive upon completion of work</param>
@ -59,14 +55,10 @@ namespace ASC.Web.Files.Core.Compress
/// Transfer the file itself to the archive /// Transfer the file itself to the archive
/// </summary> /// </summary>
/// <param name="readStream">File data</param> /// <param name="readStream">File data</param>
public void PutStream(Stream readStream) public async Task PutStream(Stream readStream)
{ {
using (var buffered = TempStream.GetBuffered(readStream)) PutNextEntry();
{ await readStream.CopyToAsync(zipStream);
zipEntry.Size = buffered.Length;
zipStream.PutNextEntry(zipEntry);
buffered.CopyTo(zipStream);
}
} }
/// <summary> /// <summary>

View File

@ -1,6 +1,7 @@
using System; using System;
using System.IO; using System.IO;
using System.Threading.Tasks;
namespace ASC.Web.Files.Core.Compress namespace ASC.Web.Files.Core.Compress
{ {
///<summary>Archiving Class Unification Interface</summary> ///<summary>Archiving Class Unification Interface</summary>
@ -18,7 +19,7 @@ namespace ASC.Web.Files.Core.Compress
/// Transfer the file itself to the archive /// Transfer the file itself to the archive
/// </summary> /// </summary>
/// <param name="readStream">File data</param> /// <param name="readStream">File data</param>
void PutStream(Stream readStream); Task PutStream(Stream readStream);
/// <summary> /// <summary>
/// Put an entry on the output stream. /// Put an entry on the output stream.