Skip to content
bitzorcas
EN

Reference

Files module

File management module — FileAssetService for upload/download/delete with tenant isolation, LocalFileStorage integration, and cross-module attachment support.

Last updated

The Files module provides tenant-scoped file asset management with upload, download, soft-delete, and pagination. Files integrate with Tickets and Chat modules as attachment providers.

Endpoints

EndpointMethodDescription
/api/filesPOSTUpload file (multipart form)
/api/files/{id}GETDownload file by asset ID
/api/files/{id}DELETESoft-delete file
/api/filesGETPaginated file listing

FileAsset entity

public class FileAssetEntity : TenantSoftDeleteEntityBase
{
public string FileName { get; set; }
public string ContentType { get; set; }
public long FileSizeBytes { get; set; }
public string StoragePath { get; set; }
public string? Description { get; set; }
}

Architecture

FileEndpoints (Minimal API)
FileAssetService
├── IFileAssetRepository → SqlSugarFileAssetRepository
├── IFileStorage → LocalFileStorage
└── IFileEventPublisher → CapFileEventPublisher

Upload flow

  1. Client sends POST /api/files with multipart form data
  2. FileAssetService reads the stream via IFileStorage.SaveAsync()
  3. Metadata persisted in FileAssetEntity via SqlSugar
  4. IFileEventPublisher publishes file.uploaded integration event
  5. Returns the file asset ID and metadata

Cross-module attachments

Files serve as the attachment backbone for other modules:

ModuleAttachment ServicePurpose
TicketsFileAssetTicketAttachmentAccessServiceAttach files to tickets
ChatFileAssetChatAttachmentAccessServiceAttach files to chat messages

Both implement module-specific access patterns:

public interface ITicketAttachmentAccessService
{
Task<FileAssetEntity?> GetAttachmentAsync(Guid attachmentId, CancellationToken ct);
}
public interface IChatAttachmentAccessService
{
Task<FileAssetEntity?> GetAttachmentAsync(Guid attachmentId, CancellationToken ct);
}

Storage configuration

{
"Storage": {
"BasePath": "./storage/files"
}
}

Files are stored at {basePath}/{year}/{month}/{guid}.{extension}.

See also