Files
admin/_docs/02_document/modules/services_resources_service.md
T
Oleksandr Bezdieniezhnykh 3a925b9b0f
ci/woodpecker/push/01-test Pipeline failed
ci/woodpecker/push/02-build-push unknown status
refactor: remove obsolete resource download and installer endpoints
- Deleted the `POST /resources/get/{dataFolder?}` and `GET /resources/get-installer` endpoints as part of the architectural shift towards simplified resource management.
- Removed associated methods and configurations, including `ResourcesService.GetEncryptedResource`, `ResourcesService.GetInstaller`, and related properties in `ResourcesConfig`.
- Cleaned up environment variables and configuration files to reflect the removal of installer-related settings.
- Eliminated the `GetResourceRequest` DTO and its validator, along with the `WrongResourceName` error code.
- Updated documentation to clarify the changes in resource handling and the retirement of per-user file encryption.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-14 04:17:55 +03:00

2.4 KiB

Module: Azaion.Services.ResourcesService

Purpose

File-based resource management: upload, list, and clear files in the server's filesystem.

Cycle 2 (2026-05-14) noteGetInstaller and GetEncryptedResource were removed along with the POST /resources/get/{dataFolder?} and GET /resources/get-installer[/stage] endpoints; the corresponding interface methods, the Security.EncryptTo dependency, and the ResourcesConfig.SuiteInstallerFolder / SuiteStageInstallerFolder properties went with them. The service is now upload + list + clear only.

Public Interface

IResourcesService

Method Signature Description
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.
  • 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

Consumers

  • Program.csPOST /resources/{dataFolder?} (upload), GET /resources/list/{dataFolder?}, POST /resources/clear/{dataFolder?}

Data Models

None.

Configuration

Uses ResourcesConfig.ResourcesFolder.

External Integrations

Local filesystem for resource storage.

Security

  • File deletion overwrites existing files before writing new ones.
  • No path traversal protection on dataFolder parameter (security audit F-2 — open).

Tests

End-to-end coverage in e2e/Azaion.E2E/Tests/ResourceTests.csFile_upload_succeeds and Upload_without_file_is_rejected_with_400_or_409_and_60_on_conflict.