Ejemplo n.º 1
0
        public void TestDownload()
        {
            IServiceCollection services = new ServiceCollection();

            services.AddScoped <IDownloadService, DownloadService>();
            ServiceProvider.Init(services);

            IDownloadService downloadService = ServiceProvider.Locator.GetService <IDownloadService>();

            downloadService.Get("http://ssps.cz/images/logo.png", "logo.png").GetAwaiter().GetResult();
            downloadService.Get("http://himawari8-dl.nict.go.jp/himawari8/img/D531106/1d/550/2017/07/10/101000_0_0.png", "earth.png").GetAwaiter().GetResult();
        }
Ejemplo n.º 2
0
        public async Task <string> DownloadImage(DateTime date, bool fixDate = true)
        {
            date = fixDate ? timeService.FixDate(date, "Tokyo Standard Time") : date;

            List <string> partialImages = new List <string>();

            for (int i = 0; i < Quality; i++)
            {
                for (int j = 0; j < Quality; j++)
                {
                    try
                    {
                        string path = await downloadService.Get(GetUrl(date, i, j), ($"{configService.BaseFolder}{i}_{j}.png"));

                        partialImages.Add(path);
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                }
            }

            return(imageService.Merge(Quality, Quality, partialImages.ToArray()));
        }
Ejemplo n.º 3
0
        public IActionResult Head(string id)
        {
            var dl = _downloadService.Get(id);

            if (dl == null)
            {
                return(NotFound());
            }

            if (!_fileProvider.GetFile(dl.PhysicalPath).Exists)
            {
                _downloadService.Remove(dl.Id);
                return(NotFound());
            }

            Context.Response.WriteFileContentHeaders(dl.PhysicalPath, _fileProvider);

            return(new EmptyResult());
        }