コード例 #1
0
        public void Delete(int id)
        {
            var forroLevel = _repository.Get(id);

            _repository.Delete(id);

            //Delete file from S3 Bucket
            //Run synchronously. Not ideal I know, but my goal is to be straightforward and learn AWS, so this is faster development
            //TODO: This logic is seriously fragile, I would never approve it during a code-review lol

            if (!string.IsNullOrWhiteSpace(forroLevel.ImageUrl))
            {
                _amazonS3.DeleteAsync(_bucketName, forroLevel.ImageUrl, null).Wait();
            }
            if (!string.IsNullOrWhiteSpace(forroLevel.ThumbNailImageUrl))
            {
                _amazonS3.DeleteAsync(_bucketName, forroLevel.ThumbNailImageUrl, null).Wait();
            }
        }
コード例 #2
0
        public async Task <bool> RemoveAsync(string relativeLocation)
        {
            var key = _locationTemplateParser.SetBase(relativeLocation, string.Empty).TrimStart('/');

            _logger.LogInformation($"Delete file: '{key}' from '{_options.BucketName}' bucket");

            await _amazonS3Client.DeleteAsync(_options.BucketName, key, new Dictionary <string, object>());

            return(true);
        }
コード例 #3
0
 public async Task DeleteAsync(string fileName, string userId)
 {
     await _client.DeleteAsync(_bucket, Path.Combine(userId, fileName), new Dictionary <string, object>());
 }