File: fix download
This commit is contained in:
parent
274e89f51c
commit
914c9bc799
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
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>
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
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>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
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
|
||||||
{
|
{
|
||||||
@ -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.
|
||||||
|
Loading…
Reference in New Issue
Block a user