DAM Core module
Edition | CE |
---|---|
License |
|
Issues |
|
Maven site |
|
Latest |
4.0.2 |
The DAM Core module is a Magnolia Maven module.
-
It has a module class (info.magnolia.dam.core.config.DamCoreConfiguration) that implements info.magnolia.module.ModuleLifecycle.
-
It contains (and registers) info.magnolia.dam.core.download.DamDownloadServlet and provides an implementation of info.magnolia.dam.api.AssetProviderRegistry.
-
The module is configured in
/modules/dam/config
.
Installing with Maven
Maven is the easiest way to install the module. Add the following to your bundle:
<dependency>
<groupId>info.magnolia.dam</groupId>
<artifactId>magnolia-dam-core</artifactId>
<version>4.0.2</version> (1)
</dependency>
1 | Should you need to specify the module version, do it using <version> . |
Asset providers and renderers
In order to have a working DAM, you must have configured at least:
-
info.magnolia.dam.api.AssetProvider
-
info.magnolia.dam.api.AssetRenderer
Configuring an asset provider
To enable DAM, at least one asset provider must be configured as a subnode of /modules/dam/config/providers/
.
Property | Description |
---|---|
|
required A class that must implement info.magnolia.dam.api.AssetProvider. |
|
required The identifier of the asset provider. Must be unique within all asset providers. |
|
optional, default is Allows you to disable the provider if, for instance, it does not have the necessary credentials to access the assets. Setting the property to |
Configuring an asset renderer
info.magnolia.dam.api.AssetRenderer objects can be configured:
-
Globally
-
Per AssetProvider
When an asset rendition is requested, AssetProviderRegistry#getRendererFor(Asset asset, MediaType to)
is first looking for a provider-specific renderer but will fallback to the globally defined renderer if no specific provider is found.
The example configuration above has two renderers defined:
-
/modules/dam/config/providers/example-provider/renderers/imaging
- configures a renderer for images specifically for theexample-provider
. -
/modules/dam/config/renderers/noOp
- a global fallback if a provider lacks a renderer for the requested media type.
NoOpAssetRenderer
The magnolia-dam-core
module provides info.magnolia.dam.core.NoOpAssetRenderer, which can be used to define a global asset renderer. By default, the NoOpAssetRenderer
only wraps the original asset.
Specific asset provider and renderer should rather be configured from a module which contains a specific implementation but not from the |
Download servlet
info.magnolia.dam.core.download.DamDownloadServlet handles
asset downloads. The main task
is to retrieve an Asset
Object based on the current URI:
-
If no
Asset
is found, an error is sent to the response. -
If an
Asset
is found, the response header is set and the asset binary is put in the response.
The servlet is backwards compatible and maps static UUIDs to the new DAM format.
DamDownloadServlet
is registered in the filter chain at /server/filters/servlets/DamDownloadServlet
.
Content disposition
Content-disposition is a HTTP header.
If the Content-disposition field is set in a HTTP response header, the browser opens the save file as
dialog instead of rendering the requested resource.
By default, the DamDownloadServlet
serves assets whose Content-Disposition
header is set. However, it is possible to define exceptions to omit the content disposition header.
Disabling content disposition headers per media (MIME) type
The standard DAM configuration already defines two exceptions based on media types:
-
application/x-shockwave-flash
-
video/mp4
To disable the Content-Disposition header for other content types, add
their media types to /dam/config/contentDisposition/contentType/rejected
.
Nodes and properties:
-
contentDisposition
: Defines content disposition header exceptions.-
contentType
: Arbitrary node name-
rejected
: Content map of MIME types for which content disposition headers are not served. -
class
: info.magnolia.voting.voters.ResponseContentTypeVoter is a Voters that checks the content type set on the response object against a list of allowed and/or rejected content types. It is typed to Object, as it can vote on both a passedHttpServletRequest
, or the currentMgnlContext.webContext
, if any.
-
-
class
: info.magnolia.voting.voters.VoterSet supports a set of voters. Voting can be set, and a level returned. If the level is not set (0
), the voting result is returned.
-
Disabling content disposition headers based on path
To disable serving Content-Disposition
headers based on path:
-
Create a new node
inline
undercontentDisposition
. -
Under the new content node, create three property nodes:
-
class
and set the value toinfo.magnolia.voting.voters.URIStartsWithVoter
. -
not
and set the value totrue
. -
pattern
and set the value to/dam/inline
.
-
-
Under the
contentDisposition
node, add theop
property and set its value toand
. This acts as an operator between voters and is only necessary if there are more than one voter in the set.
This will configure all files in the inline
folder to be sent without content disposition headers. The new content node should look like this: