Ejemplo n.º 1
0
        public async Task Top_level_folders_are_containers()
        {
            IReadOnlyCollection <Blob> containers = await _native.ListAsync();

            foreach (Blob container in containers)
            {
                Assert.Equal(BlobItemKind.Folder, container.Kind);
                Assert.True(container.Properties?.ContainsKey("IsContainer"), "isContainer property not present at all");
                Assert.Equal(true, container.Properties["IsContainer"]);
            }
        }
Ejemplo n.º 2
0
        public async Task <FilesViewModel> ListAsync()
        {
            var model = new FilesViewModel();

            try
            {
                foreach (var item in await _iAzureBlobStorage.ListAsync())
                {
                    model.Files.Add(
                        new FileDetails {
                        Name = item.Name, BlobName = item.BlobName
                    });
                }
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Error, ex.Message);
                throw;
            }
            return(model);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Index()
        {
            var model = new FilesViewModel();

            foreach (var item in await blobStorage.ListAsync())
            {
                model.Files.Add(
                    new FileDetails {
                    Name = item.Name, BlobName = item.BlobName
                });
            }
            return(View(model));
        }
        public async Task AddProcessor(IStreamHandler handler, IOptions <BlobStorageOptions> options, CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
                var blobs = await _blobStorage.ListAsync(options.Value.ContainerName, options.Value.Prefix, stoppingToken).ConfigureAwait(false);

                if (blobs != default && blobs.Count > 0)
                {
                    Parallel.ForEach(blobs,
                                     new ParallelOptions {
                        MaxDegreeOfParallelism = Environment.ProcessorCount
                    },
                                     item =>
                    {
                        _ = Run(handler, options, item, stoppingToken);
                    });
                }

                Thread.Sleep(10000);
            }
        }