Files
admin/_docs/02_document/modules/services_resources_service.md
T
Oleksandr Bezdieniezhnykh c7b297de83
ci/woodpecker/push/01-test Pipeline failed
ci/woodpecker/push/02-build-push unknown status
refactor: remove deploy.cmd and update Dockerfile for health checks
- Deleted the deploy.cmd script as it was no longer needed.
- Updated Dockerfile to include curl for health checks and added a non-root user for improved security.
- Modified health check command to use curl for better reliability.
- Adjusted docker-compose.test.yml to reflect changes in health check configuration.
- Cleaned up appsettings.json and removed unused configuration properties.
- Removed Resource entity and related requests from the codebase as part of the architectural shift.
- Updated documentation to reflect the removal of hardware binding and related endpoints.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-13 08:47:21 +03:00

2.8 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 dataFolder is null/empty, uses ResourcesConfig.ResourcesFolder directly; otherwise, appends it as a subdirectory.
  • GetInstaller: scans the installer folder for files matching "AzaionSuite.Iterative*", returns the first match as a FileStream.
  • GetEncryptedResource: opens the file, encrypts via Security.EncryptTo extension into a MemoryStream, 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.GetFiles with optional search pattern.
  • ClearFolder: iterates and deletes all files and subdirectories.

Dependencies

  • IOptions<ResourcesConfig> — folder paths
  • ILogger<ResourcesService> — logs successful saves
  • BusinessException — thrown for null file uploads
  • Security.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 (the hardware-hash component was removed by AZ-197 — see services_security.md).
  • File deletion overwrites existing files before writing new ones.
  • No path traversal protection on dataFolder parameter.

Tests

None at the module level. End-to-end coverage lives in e2e/Azaion.E2E/Tests/ResourceTests.cs (encrypted download / round-trip / 200 MB upload limit) — updated by AZ-197 to stop sending the Hardware field.