Broadleaf supports managing assets such as images and files through its Asset Service. It is responsible for storing the actual file binary whereas other services will only store references to this data. Out-of-the-box, Broadleaf stores assets on the filesystem, but other storage providers may be implemented such as an Amazon S3 bucket—see StorageProvider.
Since the Asset Service may be running on different paths and ports depending on the environment and flex package configuration and may use any of a variety of storage providers, other services will usually only store the relative file path such as /some/folder/my-image.png
rather than a full URL to remain implementation agnostic.
The base URL is then configured using a property to point to the Content Resolver Endpoint.
This base URL for the Content Resolver is then prepended onto the asset URLs when the related entity, e.g., ProductAsset
, is serialized into JSON.
This is performed by AssetContentUrlSerializer
from the Asset Consumer library, which is a type of com.fasterxml.jackson.databind.ser.std.StdSerializer
introduced by Broadleaf to extend the FasterXML Jackson serialization process.
Therefore, it is important to set broadleaf.asset.provider.content-url-prefix
appropriately for each service that makes use of entity assets such as Catalog (for Products and Categories).
By default, it should point to the Broadleaf Asset Service or whichever flexpackage it is running in.
See the Asset Services documentation, the Content Services documentation, and the Content Services documentation to learn more about this functionality.