feat(storage): stockage configurable par l'IHM — providers Fichier + S3 (Fixes #78)
- IStorageProvider (Application) : Upload/Download/Delete/DeleteBatch/Health - LocalStorageProvider : écriture atomique (tmp + move), anti path-traversal - AlarikStorageProvider : S3-compatible (AWS SDK, ForcePathStyle), upload staging→final (atomique), batch delete 1000/appel (Correctif D6) - StorageProviderFactory : provider résolu depuis les settings DB (storage.provider = Local|S3) avec fallback env, re-résolu à chaque appel - Seed idempotent des clés storage.* (catégorie 'storage') au démarrage - UI : section 'Stockage' dédiée dans SettingsPage (sélecteur Local/S3, champs conditionnels, clé secrète masquée, bouton Tester → POST /api/settings/storage/test) - Tests : 6 LocalStorageProvider (roundtrip, delete, batch, traversal, health) ; Web 217/217, Infrastructure 177/177, Application 391/391
This commit is contained in:
1 parent
2e188e4dda
commit
7d6213696f
11 files changed
+685
-1
No files matched your search
@@ -206,6 +206,39 @@ public partial class Program {
|
||||
}
|
||||
await groupDb.SaveChangesWithRetryAsync();
|
||||
|
||||
// Seed des paramètres de stockage (idempotent) — source de vérité DB,
|
||||
// valeur initiale depuis env pour migration douce (ticket #78/#80).
|
||||
var storageDefaults = new Dictionary<string, string?>
|
||||
{
|
||||
["storage.provider"] = Environment.GetEnvironmentVariable("STORAGE__PROVIDER") ?? "Local",
|
||||
["storage.local.path"] = Environment.GetEnvironmentVariable("STORAGE__LOCAL__PATH") ?? "./data/storage",
|
||||
["storage.s3.endpoint"] = Environment.GetEnvironmentVariable("ALARIK_ENDPOINT")
|
||||
?? Environment.GetEnvironmentVariable("S3_ENDPOINT"),
|
||||
["storage.s3.bucket"] = Environment.GetEnvironmentVariable("S3_BUCKET") ?? "heimdall",
|
||||
["storage.s3.accessKey"] = Environment.GetEnvironmentVariable("S3_ACCESS_KEY"),
|
||||
["storage.s3.secretKey"] = Environment.GetEnvironmentVariable("S3_SECRET_KEY"),
|
||||
["storage.s3.region"] = Environment.GetEnvironmentVariable("S3_REGION") ?? "us-east-1",
|
||||
};
|
||||
foreach (var (key, value) in storageDefaults)
|
||||
{
|
||||
if (await groupDb.AppSettings.AnyAsync(s => s.Key == key))
|
||||
continue;
|
||||
groupDb.AppSettings.Add(new Heimdall.Domain.Entities.AppSetting(
|
||||
key, value ?? string.Empty, "storage",
|
||||
key switch
|
||||
{
|
||||
"storage.provider" => "Provider de stockage actif (Local | S3)",
|
||||
"storage.local.path" => "Chemin racine du stockage local",
|
||||
"storage.s3.endpoint" => "Endpoint S3 (Alarik/MinIO)",
|
||||
"storage.s3.bucket" => "Bucket S3",
|
||||
"storage.s3.accessKey" => "Clé d'accès S3",
|
||||
"storage.s3.secretKey" => "Clé secrète S3",
|
||||
"storage.s3.region" => "Région S3",
|
||||
_ => key
|
||||
}));
|
||||
}
|
||||
await groupDb.SaveChangesWithRetryAsync();
|
||||
|
||||
// Seed demo admin + demo site when explicitly enabled (dev & E2E hosts)
|
||||
if (configuration.GetValue<bool>("Seed:DemoOnStartup", false))
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user