({{, (RefLink[ContentObject, paclet:ref/ContentObject])["string"]
gives a content object whose content is string.}, {, (RefLink[ContentObject, paclet:ref/ContentObject])[(RefLink[File, paclet:ref/File])[…]]
gives a content object whose content is stored in the specified file.}, {, (RefLink[ContentObject, paclet:ref/ContentObject])[\[LeftAssociation]"(Subscript[name, 1])"->(Subscript[val, 1]),"(Subscript[name, 2])"->(Subscript[val, 2]),…\[RightAssociation]]
gives a content object with a sequence of fields with names (Subscript[name, i]) and values (Subscript[val, i]).}})

OpenersNotesSection(Spacer1)Details

Properties of content objects can be obtained using (RefLink[ContentObject, paclet:ref/ContentObject])[…]["property"].

Possible properties can include:

Some properties, such as "Snippet", are typically only computed when requested.

When a content object is created from a file, the "Plaintext" property will typically be computed by first importing the file.

(RefLink[ContentObject, paclet:ref/ContentObject])[…] can be used in the input to (RefLink[CreateSearchIndex, paclet:ref/CreateSearchIndex]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (3)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

(RefLink[TextSearch, paclet:ref/TextSearch]) with "ContentObject" as third argument returns a list of content objects:

TextSearch["ExampleData/Text", "dog","ContentObject"]

Get the file name of the first result:

co=First[%];
co["FileName"]

Create an object containing some text:

file=AbsoluteFileName[Export["alice.txt",ExampleData[{"Text", "AliceInWonderland"}]]];
doc=ContentObject[File[file]]

Get only a snippet of the text:

doc["Snippet"]

It is also possible to use the (RefLink[Snippet, paclet:ref/Snippet]) function:

Snippet[doc]

Get properties of the file:

doc["Location"]

doc["FileName"]

doc["FileExtension"]

doc["FileSize"]

A (RefLink[ContentObject, paclet:ref/ContentObject]) can contain a string:

doc2= ContentObject["This is a string"]

(RefLink[ContentObject, paclet:ref/ContentObject]) contains metadata:

InputForm[doc2]

(StringTypeLink["Location", paclet:ref/interpreter/Location]) and (StringTypeLink["FileName", paclet:ref/interpreter/FileName]) are not available if the document is not saved on disk:

doc2["Location"]

doc2["FileName"]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[TextSearch, paclet:ref/TextSearch])  ▪  (RefLink[Snippet, paclet:ref/Snippet])  ▪  (RefLink[File, paclet:ref/File])  ▪  (RefLink[URL, paclet:ref/URL])  ▪  (RefLink[NotebookObject, paclet:ref/NotebookObject])  ▪  (RefLink[ContentFieldOptions, paclet:ref/ContentFieldOptions])  ▪  (RefLink[ContentLocationFunction, paclet:ref/ContentLocationFunction])  ▪  (RefLink[ResourceObject, paclet:ref/ResourceObject])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Text Search, paclet:guide/TextSearch])}, {▪(RefLinkPlain[Wolfram Data Repository, paclet:guide/WolframDataRepository])}})}})