Binaries That Require Workflow
To apply workflow to a binary file, such as a PDF, use an embedded resource. An embedded resource is a binary stored within a document. When you configure workflow for the document, the embedded binary inherits the same workflow.
Do not store binaries that require workflow in an asset folder. Assets in asset folders are published immediately and are publicly accessible without workflow.
Note:
Use embedded resources within a document when you need workflow for a binary file.
Implementation Steps
Step 1: Add an Embedded Resource to a Document Type
- In the CMS Template Editor, open the relevant document type (for example, "news article").
- Add a new field of type Compound Field and select the Resource field.
- Update the Caption (for example, to "My Asset") and set the path (for example, "asset").
- Save and commit your changes.
- You can now add an embedded resource to a news article in the CMS.
Step 2: Update the Java Bean
- In your HST project, update the Java bean that represents the modified document type.
- Add a getter method for the embedded resource field. For example:
public HippoResourceBean getAsset() { return getBean("my_namespace:asset"); }
Step 3: Add a Download Link in the Template
- Update your JSP or Freemarker template to include a download link for the embedded asset. For example:
<hst:link var="assetLink" hippobean="${newsDoc.asset}"/> <a href="${assetLink}">Download</a> : ${newsDoc.asset.lengthMB} MB. Type = ${newsDoc.asset.mimeType}
This approach ensures that the binary file follows the document's workflow and is not published until the document is published.