Пример #1
0
        public async Task Consume(ConsumeContext <DeleteSource> context)
        {
            var blobInfo = await _blobStorage.GetFileInfo(context.Message.Id, context.Message.Bucket);

            var doc = await _imagesMetaCollection.FindOneAndDeleteAsync(fd => fd.Id == context.Message.Id);

            Log.Information($"Deleting blob '{context.Message.Id}'.");
            if (!(blobInfo is null))
            {
                await _blobStorage.DeleteFileAsync(context.Message.Id, context.Message.Bucket);

                if (!(doc is null))
                {
                    foreach (var image in doc.Images)
                    {
                        var imageInfo = await _blobStorage.GetFileInfo(image.Id, context.Message.Bucket);

                        if (!(imageInfo is null))
                        {
                            Log.Information($"Deleting image '{image.Id}'.");
                            await _blobStorage.DeleteFileAsync(image.Id, context.Message.Bucket);
                        }
                    }
                }

                await context.Publish <SourceDeleted>(new
                {
                    Id            = context.Message.Id,
                    Bucket        = context.Message.Bucket,
                    CorrelationId = context.Message.CorrelationId,
                    UserId        = context.Message.UserId,
                    TimeStamp     = DateTimeOffset.UtcNow
                });
            }
        }
Пример #2
0
        public async Task Consume(ConsumeContext <DeleteStandardization> context)
        {
            await blobStorage.DeleteFileAsync(context.Message.Id);

            await context.Publish <StandardizationDeleted>(new
            {
                Id            = context.Message.Id,
                UserId        = context.Message.UserId,
                TimeStamp     = DateTimeOffset.UtcNow,
                CorrelationId = context.Message.CorrelationId
            });
        }
Пример #3
0
        public async Task <IActionResult> Delete(Guid id, string bucket)
        {
            Log.Information($"Deleting file '{id}' in bucket '{bucket}'");

            var blobInfo = await _blobStorage.GetFileInfo(id, bucket);

            if (blobInfo != null)
            {
                await _blobStorage.DeleteFileAsync(id, bucket);

                Log.Information($"File '{id}' deleted.");

                return(Ok());
            }
            else
            {
                Log.Warning($"File '{id}' not found.");

                return(NotFound());
            }
        }