File: fix download
This commit is contained in:
parent
274e89f51c
commit
914c9bc799
@ -16,6 +16,7 @@
|
||||
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using ASC.Common;
|
||||
using ASC.Files.Core.Resources;
|
||||
@ -34,12 +35,6 @@ namespace ASC.Web.Files.Core.Compress
|
||||
private GZipOutputStream gzoStream;
|
||||
private TarOutputStream gzip;
|
||||
private TarEntry tarEntry;
|
||||
private TempStream TempStream { get; }
|
||||
|
||||
public CompressToTarGz(TempStream tempStream)
|
||||
{
|
||||
TempStream = tempStream;
|
||||
}
|
||||
|
||||
/// <summary></summary>
|
||||
/// <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
|
||||
/// </summary>
|
||||
/// <param name="readStream">File data</param>
|
||||
public void PutStream(Stream readStream)
|
||||
public async Task PutStream(Stream readStream)
|
||||
{
|
||||
using (var buffered = TempStream.GetBuffered(readStream))
|
||||
{
|
||||
tarEntry.Size = buffered.Length;
|
||||
gzip.PutNextEntry(tarEntry);
|
||||
buffered.CopyTo(gzip);
|
||||
}
|
||||
PutNextEntry();
|
||||
await readStream.CopyToAsync(gzip);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using ASC.Common;
|
||||
using ASC.Files.Core.Resources;
|
||||
@ -31,12 +32,7 @@ namespace ASC.Web.Files.Core.Compress
|
||||
{
|
||||
private ZipOutputStream zipStream;
|
||||
private ZipEntry zipEntry;
|
||||
private TempStream TempStream { get; }
|
||||
|
||||
public CompressToZip(TempStream tempStream)
|
||||
{
|
||||
TempStream = tempStream;
|
||||
}
|
||||
|
||||
/// <summary> </summary>
|
||||
/// <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
|
||||
/// </summary>
|
||||
/// <param name="readStream">File data</param>
|
||||
public void PutStream(Stream readStream)
|
||||
public async Task PutStream(Stream readStream)
|
||||
{
|
||||
using (var buffered = TempStream.GetBuffered(readStream))
|
||||
{
|
||||
zipEntry.Size = buffered.Length;
|
||||
zipStream.PutNextEntry(zipEntry);
|
||||
buffered.CopyTo(zipStream);
|
||||
}
|
||||
PutNextEntry();
|
||||
await readStream.CopyToAsync(zipStream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ASC.Web.Files.Core.Compress
|
||||
{
|
||||
@ -18,7 +19,7 @@ namespace ASC.Web.Files.Core.Compress
|
||||
/// Transfer the file itself to the archive
|
||||
/// </summary>
|
||||
/// <param name="readStream">File data</param>
|
||||
void PutStream(Stream readStream);
|
||||
Task PutStream(Stream readStream);
|
||||
|
||||
/// <summary>
|
||||
/// Put an entry on the output stream.
|
||||
|
Loading…
Reference in New Issue
Block a user