Skip to content
bitzorcas
EN

Reference

Storage building block

File storage abstraction — IFileStorage port with LocalFileStorage default implementation, FileAssetService for upload/download/management, and future cloud storage adapter roadmap.

Last updated

The Storage building block provides an abstraction for file storage with a local filesystem implementation. The Files platform module builds on top of this for upload/download/management operations.

IFileStorage port

public interface IFileStorage
{
Task<string> SaveAsync(
Stream stream,
string contentType,
string extension,
CancellationToken ct = default);
Task<Stream?> ReadAsync(
string path,
CancellationToken ct = default);
Task DeleteAsync(
string path,
CancellationToken ct = default);
}

LocalFileStorage

The default implementation saves files to a local directory:

public class LocalFileStorage : IFileStorage
{
// Generates unique path: {basePath}/{year}/{month}/{guid}.{extension}
// Returns relative path for storage in database
}

Configuration

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

File naming convention

Files are organized by date to prevent directory bloat:

./storage/files/
├── 2026/
│ ├── 06/
│ │ ├── a1b2c3d4.pdf
│ │ ├── e5f6g7h8.png
│ │ └── i9j0k1l2.csv
│ └── 07/
│ └── ...

FileAssetService

The Files platform module provides higher-level file management:

OperationEndpointDescription
UploadPOST /api/filesUpload file with metadata
DownloadGET /api/files/{id}Download by asset ID
DeleteDELETE /api/files/{id}Soft-delete file asset
ListGET /api/filesPaginated 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; }
}

Module integration

File storage integrates with other modules:

  • TicketsFileAssetTicketAttachmentAccessService links file assets to tickets
  • ChatFileAssetChatAttachmentAccessService links file assets to chat messages
  • Webhooks — webhook payloads can reference file attachments

Roadmap: Cloud storage adapters

Planned cloud storage implementations:

AdapterTarget
S3 StorageAWS S3, MinIO, compatible providers
Azure BlobAzure Blob Storage
Alibaba OSSAlibaba Cloud Object Storage

All will implement IFileStorage — switchable via configuration.