Ejemplo n.º 1
0
        public async Task <List <UploadResult> > Handle(T request, CancellationToken cancellationToken)
        {
            int count = 0;

            request.Files.ForEach(f =>
            {
                request.Response.Add(new UploadResult(f.Tag));
            });

            foreach (var file in request.Files)
            {
                cancellationToken.ThrowIfCancellationRequested();

                await storageProvider.Upload(file.Tag, file.Content);

                await databaseProvider.Persist(new BlobEntity()
                {
                    Tag = file.Tag
                });

                var response = request.Response.Find(r => r.Tag == file.Tag);

                response.SetUrl(storageProvider.GetBlobUrl(file.Tag));
                response.SetStatus(UploadResult.Status.Succeeded);

                count++;
                request.Counter?.Invoke();
            }

            return(request.Response);
        }