File Upload
Azure Blob Storage integration with chunked upload support for large files. Files are organized by mode and tracked in the database as AzureFileObj records. Supports the Meta Graph API Resumable Upload flow for WhatsApp media attachments.
When to use this module
- Upload images or documents for contacts or WhatsApp messages
- Attach WhatsApp message media → upload, then use
fileIdin the message payload - Upload a CSV import file →
Mode=Import, passfileIdto the import endpoint
Endpoints
| Method | Route | Auth | Description |
|---|---|---|---|
| POST | /api/v1/Files/chunk | Upload chunk(s) to Azure Blob (multipart/form-data) |
Chunk Upload — Form Fields
The chunk upload endpoint accepts multipart/form-data. The endpoint handles both single-chunk (small) and multi-chunk (large) uploads — the difference is in how many calls you make.
| Field | Type | Required | Description |
|---|---|---|---|
File | IFormFile | required | The binary file chunk to upload |
BlockIndex | int | required | Zero-based chunk index (0 for first chunk) |
TotalBlocks | int | required | Total number of chunks for this file |
Mode | enum | required | Firm / Profile / Contact / Message / Template / Import |
FileId | Guid? | optional | Required for chunks after the first (BlockIndex > 0) to correlate parts |
Single-Chunk Upload Flow
For small files (e.g., profile pictures, logos), send the entire file as one chunk with TotalBlocks=1.
Multi-Chunk Upload Flow
For large files, split into chunks and send sequentially. The server stages each block until the final chunk triggers the commit.
FileId from the first response and pass it in all subsequent chunk requests. The server uses it to group blocks before committing.Blob Container Organization
All files are stored in a single Azure Blob container (configurable). The Mode determines the path prefix within the container.
| Mode | Blob Path | Usage |
|---|---|---|
Firm | firms/{firmId}/ | Logos (light, dark, favicon) |
Profile | profiles/{userId}/ | User profile pictures |
Contact | contacts/{firmId}/ | Contact profile pictures |
Message | messages/{firmId}/ | WhatsApp message attachments |
Template | templates/{firmId}/ | WhatsApp template media files |
Import | imports/{firmId}/ | CSV contact import files |
Upload Response
{
"isSuccess": true,
"data": {
"fileId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"url": "https://accountname.blob.core.windows.net/uploads/profiles/userId/filename.jpg",
"isComplete": true
},
"message": "File uploaded successfully"
}Meta Resumable Upload (WhatsApp Media)
/files/chunk and pass the returned fileId in the message/template payload.