예제 #1
0
        public async Task <IActionResult> OnPost(IFormFileCollection uploadedFiles, string archiveType)
        {
            if (uploadedFiles != null)
            {
                ArchiveSettings settings   = new ArchiveSettings(archiveType);
                IArchivator     archivator = ArchivatorFactory.CreateArchivator(settings);
                if (archivator != null)
                {
                    try
                    {
                        string archivePath = await archivator.CompressToFile(uploadedFiles, _appEnvironment.WebRootPath);

                        return(PhysicalFile(archivePath, "application/" + Path.GetExtension(archivePath), Path.GetFileName(archivePath)));
                    }
                    catch (Exception e)
                    {
                        return(Content(e.Message));
                    }
                }
                else
                {
                    return(Content("Error: Cannot create an archivator"));
                }
            }
            return(RedirectToAction("Index"));
        }
예제 #2
0
        public GZipArchivator(Settings settings)
        {
            var factory = ArchivatorFactory.CreateFactory(settings);

            _reader    = factory.GetReader();
            _writer    = factory.GetWriter();
            _processor = factory.GetBlockProcessor();

            _processingBuffer = new BlockingQueue <Block>();
            _writingBuffer    = new BlockingDictionary <int, Block>();
            _blocksLimiter    = new Semaphore(settings.BlocksLimit, settings.BlocksLimit);
        }