/// <inheritdoc /> public async Task <bool> ExistsAsync(StorageExistsOptions options, CancellationToken cancellationToken = default) { ValidateFileName(options.Container); ValidateFileName(options.FileName); _logger.LogDebug("Checking if file {FileName} from container {Container} exists", options.FileName, options.Container); var request = new GetObjectRequest { BucketName = _bucketName, Key = GetFileKey(options.Container, options.FileName), }; try { var response = await _client.GetObjectAsync(request, cancellationToken); _disposables.Add(response); } catch (AmazonS3Exception ex) { return(ex.ErrorCode switch { "NoSuchKey" => false, "AccessDenied" => true, "PermanentRedirect" => true, _ => throw ex, });
/// <inheritdoc /> public Task <bool> ExistsAsync(StorageExistsOptions options, CancellationToken cancellationToken = default) { ValidateFileName(options.Container); ValidateFileName(options.FileName); _logger.LogDebug("Checking if file {FileName} from container {Container} exists", options.FileName, options.Container); return(Task.FromResult(File.Exists(GetFileLocation(options.Container, options.FileName)))); }
/// <inheritdoc /> public Task <bool> ExistsAsync(StorageExistsOptions options, CancellationToken cancellationToken = default) { return(Task.FromResult(_contents.ContainsKey(GetFileKey(options.Container, options.FileName)))); }