Here’s a comprehensive solution addressing all three aspects of your mobile attachment sync issues:
1. Offline Sync Logic Enhancement:
Your current sync implementation treats attachments as atomic uploads, which fails for large files. Modify your offline sync workflow to handle attachments differently from case data:
- Separate Sync Queues: Maintain separate queues for case data and attachments in the mobile app’s local storage
- Priority Sync: Upload case data first (fast), then process attachments sequentially
- Resume Capability: Track upload progress locally so interrupted uploads can resume from the last successful chunk
- Retry Logic: Implement exponential backoff for failed attachment uploads (retry after 30s, 60s, 120s)
In your mobile app configuration (MobileChannel rule), enable advanced sync options:
- Set SyncStrategy to “Differential” for attachments
- Enable background sync so uploads continue even if the app is minimized
- Configure sync status notifications so agents know when uploads complete
2. Attachment Size Limits & Compression:
Implement a multi-tier approach to handle various file sizes:
Client-Side Optimization:
Configure image compression in your mobile app’s media capture settings. Add this to your mobile channel configuration:
ImageQuality: 85
MaxResolution: 2560x1920
Format: JPEG
This reduces typical 12MB photos to 3-4MB while maintaining inspection-quality resolution.
Size-Based Upload Strategy:
- Files < 5MB: Standard single-request upload (current method)
- Files 5-15MB: Chunked upload with 2MB chunks
- Files > 15MB: Prompt user to compress or warn about long upload time
Set explicit size limits in your attachment service rule:
- Maximum single file: 50MB (server-side enforcement)
- Maximum total attachments per case: 200MB
- Return clear error messages when limits exceeded
3. Chunked Upload Implementation:
Implement chunked upload support for large files:
Mobile App Side:
Modify your attachment upload activity to detect file size and choose upload method:
if (fileSize > 5MB) {
uploadChunked(file, chunkSize: 2MB);
} else {
uploadStandard(file);
}
Server-Side API Configuration:
Create a new REST service endpoint for chunked uploads: `/api/v1/attachments/chunked
Service implementation:
- Accept multipart/form-data with chunk metadata (chunk number, total chunks, file ID)
- Store chunks temporarily in a staging area
- When final chunk received, reassemble file and attach to case
- Return chunk confirmation after each successful upload
Data Transform for Chunk Processing:
Set .ChunkNumber = Primary.ChunkNumber
Set .TotalChunks = Primary.TotalChunks
Set .FileID = Primary.FileID
Set .ChunkData = Primary.ChunkData
Validate chunk sequence and reassemble when complete.
Timeout Configuration:
Increase timeout settings for attachment uploads:
- Mobile app network timeout: 120 seconds (allows 2MB chunk upload on slower connections)
- Server-side timeout: 180 seconds
- Keep-alive interval: 30 seconds to prevent connection drops
Configure these in your mobile app’s network profile and corresponding REST service.
Implementation Steps:
- Update mobile channel to enable image compression (immediate improvement)
- Increase sync timeout to 120s in mobile network settings
- Implement chunked upload REST service for files > 5MB
- Update mobile app’s attachment upload logic to use chunked method
- Add sync status tracking and resume capability
- Test with various file sizes and network conditions
Expected Results:
- Files < 5MB: Upload in 5-15 seconds on 4G
- Files 5-15MB: Upload in 30-90 seconds via chunked method
- Failed uploads automatically retry without user intervention
- Agents see clear progress indicators during sync
This solution eliminates attachment sync failures while maintaining photo quality for compliance requirements. The chunked upload approach is especially critical for field agents on unreliable cellular networks.