s3: add s3 health check

This commit is contained in:
Abdullah Atta
2025-11-05 22:42:58 +05:00
parent 54d0fdcf4f
commit de23ea3e66
3 changed files with 28 additions and 13 deletions
+18 -12
View File
@@ -28,6 +28,7 @@ using Amazon.Runtime;
using Amazon.S3;
using Amazon.S3.Model;
using Microsoft.Extensions.Options;
using MongoDB.Driver;
using Notesnook.API.Helpers;
using Notesnook.API.Interfaces;
using Notesnook.API.Models;
@@ -65,18 +66,7 @@ namespace Notesnook.API.Services
public S3Service(ISyncItemsRepositoryAccessor syncItemsRepositoryAccessor)
{
Repositories = syncItemsRepositoryAccessor;
var config = new AmazonS3Config
{
#if (DEBUG || STAGING)
ServiceURL = Servers.S3Server.ToString(),
#else
ServiceURL = Constants.S3_SERVICE_URL,
AuthenticationRegion = Constants.S3_REGION,
#endif
ForcePathStyle = true,
SignatureMethod = SigningAlgorithm.HmacSHA256,
SignatureVersion = "4"
};
var config = CreateConfig();
#if (DEBUG || STAGING)
S3Client = new AmazonS3Client("S3RVER", "S3RVER", config);
#else
@@ -98,6 +88,22 @@ namespace Notesnook.API.Services
AWSConfigsS3.UseSignatureVersion4 = true;
}
public static AmazonS3Config CreateConfig()
{
return new AmazonS3Config
{
#if (DEBUG || STAGING)
ServiceURL = Servers.S3Server.ToString(),
#else
ServiceURL = Constants.S3_SERVICE_URL,
AuthenticationRegion = Constants.S3_REGION,
#endif
ForcePathStyle = true,
SignatureMethod = SigningAlgorithm.HmacSHA256,
SignatureVersion = "4"
};
}
public async Task DeleteObjectAsync(string userId, string name)
{
var objectName = GetFullObjectName(userId, name) ?? throw new Exception("Invalid object name.");