mirror of
https://github.com/azaion/admin.git
synced 2026-04-23 10:56:34 +00:00
d320d6dd59
Made-with: Cursor
2.5 KiB
2.5 KiB
Module: Azaion.Services.ResourcesService
Purpose
File-based resource management: upload, list, download (encrypted), clear, and installer retrieval from the server's filesystem.
Public Interface
IResourcesService
| Method | Signature | Description |
|---|---|---|
GetInstaller |
(string?, Stream?) GetInstaller(bool isStage) |
Returns the latest installer file (prod or stage) |
GetEncryptedResource |
Task<Stream> GetEncryptedResource(string? dataFolder, string fileName, string key, CancellationToken ct) |
Reads a file and returns it AES-encrypted |
SaveResource |
Task SaveResource(string? dataFolder, IFormFile data, CancellationToken ct) |
Saves an uploaded file to the resource folder |
ListResources |
Task<IEnumerable<string>> ListResources(string? dataFolder, string? search, CancellationToken ct) |
Lists file names in a resource folder, optionally filtered |
ClearFolder |
void ClearFolder(string? dataFolder) |
Deletes all files and subdirectories in the specified folder |
Internal Logic
- GetResourceFolder: resolves the target directory. If
dataFolderis null/empty, usesResourcesConfig.ResourcesFolderdirectly; otherwise, appends it as a subdirectory. - GetInstaller: scans the installer folder for files matching
"AzaionSuite.Iterative*", returns the first match as aFileStream. - GetEncryptedResource: opens the file, encrypts via
Security.EncryptToextension into aMemoryStream, returns the encrypted stream. - SaveResource: creates the folder if needed, deletes any existing file with the same name, then copies the uploaded file.
- ListResources: uses
DirectoryInfo.GetFileswith optional search pattern. - ClearFolder: iterates and deletes all files and subdirectories.
Dependencies
IOptions<ResourcesConfig>— folder pathsILogger<ResourcesService>— logs successful savesBusinessException— thrown for null file uploadsSecurity.EncryptTo— stream encryption extension
Consumers
Program.cs— all/resources/*endpoints
Data Models
None.
Configuration
Uses ResourcesConfig (ResourcesFolder, SuiteInstallerFolder, SuiteStageInstallerFolder).
External Integrations
Local filesystem for resource storage.
Security
- Resources are encrypted per-user using a key derived from email + password + hardware hash
- File deletion overwrites existing files before writing new ones
- No path traversal protection on
dataFolderparameter
Tests
None.