ApexIntermediatefilescontentattachments
Implement ContentDocument and file handling in Apex
Real World Scenario
Case auto-closure must archive email attachments to external storage via Apex without hitting heap limits.
Expected Answer
• Query ContentDocumentLink for Case related files
• ContentVersion.VersionData access aware of heap for large files
• Batch process files one at a time with callout upload
• Delete or retain files per retention policy after successful upload
• Handle file type restrictions and virus scan integration hook
• Test with small binary in unit test mock
• Governor limits on ContentVersion queries
Follow-Up Questions & Answers
Click to expand — each follow-up includes a direct, interview-ready answer
Main difference: use case and scale. Query ContentDocumentLink for Case related files. ContentVersion.VersionData access aware of heap for large files. Pick based on your integration pattern and team capability. Large file processing always async—never load multi-MB VersionData in trigger. Balance speed of delivery with maintainability.
Architect Perspective
Large file processing always async—never load multi-MB VersionData in trigger.