Content Fragments

A content fragment is a special type of asset. It can be used to access structured data, such as texts, numbers, dates, among others. As there are several differences to standard assets (such as images or documents), some additional rules apply to handling content fragments.

For further information see Content Fragments Support in the Experience Manager Assets HTTP API.

Data model

The Assets HTTP API exposes two major elements, folders and assets (for standard assets).

Additionally, it exposes more detailed elements for the custom data models that describe structured content in Content Fragments. See Content Fragment Data Models for further information.

Folders

Folders are like directories in traditional file systems. They are containers for other folders or asserts. Folders have the following components:

Entities: The entities of a folder are its child elements, which can be folders and assets.

Properties:

  • name is the name of the folder. This is the same as the last segment in the URL path without the extension.
  • title is an optional title of the folder which can be displayed instead of its name.
NOTE
Some properties of folder or asset are mapped to a different prefix. The jcr prefix of jcr:title, jcr:description, and jcr:language are replaced with dc prefix. Hence in the returned JSON, dc:title and dc:description contain the values of jcr:title and jcr:description, respectively.

Links Folders expose three links:

  • self: Link to itself.
  • parent: Link to the parent folder.
  • thumbnail: (Optional) link to a folder thumbnail image.

Assets

In Experience Manager an asset contains the following elements:

  • The properties and metadata of the asset.
  • Multiple renditions such as the original rendition (which is the originally uploaded asset), a thumbnail and various other renditions. Additional renditions may be images of different sizes, different video encodings, or extracted pages from PDF or Adobe InDesign files.
  • Optional comments.

For information about elements in Content Fragments see Content Fragments Support in Experience Manager Assets HTTP API.

In Experience Manager a folder has the following components:

  • Entities: The children of assets are its renditions.
  • Properties.
  • Links.

The Assets HTTP API includes the following features:

NOTE
For the ease of readability the following examples omit the full cURL notation. In fact the notation does correlate with Resty which is a script wrapper for cURL.

Prerequisites

  • Access https://[aem_server]:[port]/system/console/configMgr.
  • Navigate to Adobe Granite CSRF Filter.
  • Make sure the property Filter Methods includes: POST, PUT, DELETE.

Retrieve a folder listing

Retrieves a Siren representation of an existing folder and of its child entities (subfolders or assets).

Request: GET /api/assets/myFolder.json

Response codes: The response codes are:

  • 200 - OK - success.
  • 404 - NOT FOUND - folder does not exist or is not accessible.
  • 500 - INTERNAL SERVER ERROR - if something else goes wrong.

Response: The class of the entity returned is an asset or a folder. The properties of contained entities are a subset of the full set of properties of each entity. To obtain a full representation of the entity, clients should retrieve the contents of the URL pointed to by the link with a rel of self.

Create a folder

Creates a new sling: OrderedFolder at the given path. If a * is provided instead of a node name, the servlet uses the parameter name as node name. Accepted as request data is either a Siren representation of the new folder or a set of name-value pairs, encoded as application/www-form-urlencoded or multipart/ form- data, useful for creating a folder directly from an HTML form. Additionally, properties of the folder can be specified as URL query parameters.

An API call fails with a 500 response code if the parent node of the provided path does not exist. A call returns a response code 409 if the folder already exists.

Parameters: name is the folder name.

Request

  • POST /api/assets/myFolder -H"Content-Type: application/json" -d '{"class":"assetFolder","properties":{"jcr:title":"My Folder"}}'
  • POST /api/assets/* -F"name=myfolder" -F"jcr:title=My Folder"

Response codes: The response codes are:

  • 201 - CREATED - on successful creation.
  • 409 - CONFLICT - if folder already exist.
  • 412 - PRECONDITION FAILED - if root collection cannot be found or accessed.
  • 500 - INTERNAL SERVER ERROR - if something else goes wrong.

Create an asset

Place the provided file at the provided path to create an asset in the DAM repository. If a * is provided instead of a node name, the servlet uses the parameter name or the file name as node name.

Parameters: The parameters are name for the asset name and file for the file reference.

Request

  • POST /api/assets/myFolder/myAsset.png -H"Content-Type: image/png" --data-binary "@myPicture.png"
  • POST /api/assets/myFolder/* -F"name=myAsset.png" -F"file=@myPicture.png"

Response codes: The response codes are:

  • 201 - CREATED - if Asset has been created successfully.
  • 409 - CONFLICT - if Asset already exist.
  • 412 - PRECONDITION FAILED - if root collection cannot be found or accessed.
  • 500 - INTERNAL SERVER ERROR - if something else goes wrong.

Update an asset binary

Updates an asset’s binary (rendition with name original). An update triggers the default asset processing workflow to execute, if it is configured.

Request: PUT /api/assets/myfolder/myAsset.png -H"Content-Type: image/png" --data-binary @myPicture.png

Response codes: The response codes are:

  • 200 - OK - if Asset has been updated successfully.
  • 404 - NOT FOUND - if Asset could not be found or accessed at the provided URI.
  • 412 - PRECONDITION FAILED - if root collection cannot be found or accessed.
  • 500 - INTERNAL SERVER ERROR - if something else goes wrong.