public async Task ProcessAsync(Services.Minio.Minio minio, Record record)
        {
            if (!_buckets.Contains(record.S3.Bucket.Name)) // Only file in the right bucket
            {
                return;
            }

            var created = record.EventName.StartsWith("s3:ObjectCreated:");
            var removed = !created && record.EventName.StartsWith("s3:ObjectRemoved:");

            if (created || removed)
            {
                var mimeType = record.S3.Object.ContentType;
                if (mimeType == null)
                {
                    new FileExtensionContentTypeProvider().TryGetContentType(record.S3.Object.Key, out mimeType);
                }

                if (!_acceptedFormats.Contains(mimeType)) // Supported mimetypes
                {
                    return;
                }

                var lastDotIndex = record.S3.Object.Key.LastIndexOf('.');
                var ext          = record.S3.Object.Key.Substring(lastDotIndex + 1);
                var fileName     = System.Web.HttpUtility.UrlDecode(record.S3.Object.Key.Substring(0, lastDotIndex));

                if (Regex.IsMatch(fileName, @".+_\d+$"))
                {
                    return; // File already resized.
                }
                if (created)
                {
                    Bitmap source;
                    using (var memoryStream = new MemoryStream())
                    {
                        await minio.Client.GetObjectAsync(
                            record.S3.Bucket.Name,
                            System.Web.HttpUtility.UrlDecode(record.S3.Object.Key),
                            (stream) => stream.CopyTo(memoryStream));

                        source = MediaService.GetBipmapFromStream(memoryStream);
                    }

                    foreach (var size in _thumbnailSize)
                    {
                        try
                        {
                            using (var memoryStream = new MemoryStream())
                            {
                                var resized         = MediaService.ResizeBitmap(source, size, size);
                                var resizedFileName = fileName + "_" + size + "." + ext;
                                resized.Save(memoryStream, MediaService.MimeTypeToImageFormat(record.S3.Object.ContentType));
                                memoryStream.Position = 0;
                                Console.WriteLine("Uploading resized file: " + resizedFileName + ", size: " + memoryStream.Length);
                                await minio.Client.PutObjectAsync(
                                    record.S3.Bucket.Name,
                                    resizedFileName,
                                    memoryStream,
                                    -1,
                                    mimeType,
                                    metaData : record.S3.Object.UserMetadata);
                            }
                        }
                        catch (Exception e)
                        {
                            Debug.WriteLine(e.Message);
                            throw;
                        }
                    }
                }
                else if (removed)
                {
                    IObservable <Item> observable = minio.Client.ListObjectsAsync(record.S3.Bucket.Name, fileName, true);

                    observable.Subscribe <Item>(async item =>
                    {
                        if (Regex.IsMatch(item.Key, fileName + @"_\d+\." + ext + "$"))
                        {
                            await minio.Client.RemoveObjectAsync("img", System.Web.HttpUtility.UrlDecode(item.Key));
                        }
                    });
                }
            }
        }