Skip to main content

From what I understand thus far about content bodies, they're essentially the body of a file that is uploaded to SF. Documents are files that have been linked to a record, and attachments are files that have not been linked. Do I have that right? 

 

I am trying to figure this all out in terms of our storage usage. If content bodies are the file itself, why don't the counts match?  Do attachments have content bodies? Are documents just the metadata for the content bodies?  

 

#Files Storage

 

 

Storage Usage: Overlap?

 

 

2 respostas
  1. 19 de ago., 14:51

    A couple of these are flipped, and sorting them out explains the mismatch. There are actually THREE different file models in Salesforce, and they store their bytes in different places: 

     

    1. Classic Documents (the Document object): these live in Document folders (the Documents tab) and are NOT linked to a record. People use them for things like email-template images, logos, mail-merge templates. The bytes are in the Document Body field. So it is the reverse of what you had, Documents are the ones NOT tied to a record. 

     

    2. Classic Attachments (the Attachment object): these ARE linked to a specific record, via ParentId (an Attachment must have a parent). The bytes live in the Attachment Body field. So Attachments are the record-linked ones. 

     

    3. Salesforce Files (the modern model): this is ContentDocument (the file) plus ContentVersion (each version of it, where the actual bytes live, in the VersionData field) plus ContentDocumentLink (which records it is shared to). A single File can be linked to many records, or none. This is what most 'content body' language refers to, the file binary is on ContentVersion. 

     

    On your specific questions: 

    - Do attachments have content bodies? Not in the Files sense. An Attachment stores its own bytes in its Body field, it is a separate legacy object, not part of the ContentDocument/ContentVersion model. 

    - Are documents just metadata for content bodies? No, a Document has its own Body field with the actual bytes, it is not a pointer to a ContentVersion. 

     

    Why the counts do not match: 

    - Storage is split into File Storage and Data Storage. Documents, Attachments, and Files (ContentVersions) all consume File Storage, while records consume Data Storage, so a record count and a storage-MB figure will not line up. 

    - Within Files, every ContentVersion (every version of a file) counts its own bytes, so one file with 3 versions consumes 3x. That alone throws off naive counts. 

    - A single File linked to 5 records is ONE ContentDocument with 5 ContentDocumentLinks, counted once for storage but it can look like 5 items in related lists. 

     

    For auditing, Setup > Storage Usage is the cleanest view, and for the Files model query ContentVersion (ContentSize) rather than counting links. 

     

    If this helps, please mark it as the Best Answer so it helps the next person. Thanks :)

0/9000