File download for attached file assets
parent
8491c01d8b
commit
8871eecea3
|
|
@ -3,7 +3,7 @@
|
|||
</#macro>
|
||||
|
||||
<#macro "org.librecms.assets.FileAsset" asset>
|
||||
<h3><a href="${asset.assetPath}">${asset.title}</a></h3>
|
||||
<h3><a href="/content-sections/${asset.contentSection}/files${asset.assetPath}">${asset.title}</a></h3>
|
||||
<p>${asset.description}</p>
|
||||
<small>${asset.mimeType} ${asset.size} Bytes</small>
|
||||
<#-- <p><code>A file asset</code></p> -->
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import java.util.Optional;
|
|||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.transaction.Transactional;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
|
|
@ -44,7 +45,7 @@ import javax.ws.rs.core.StreamingOutput;
|
|||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
@Path("/{content-section}/files")
|
||||
@Path("/{content-section}/files/")
|
||||
public class Files {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(Files.class);
|
||||
|
|
@ -60,6 +61,7 @@ public class Files {
|
|||
|
||||
@GET
|
||||
@Path("/uuid-{uuid}")
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public Response getFileByUuid(
|
||||
@PathParam("content-section") final String sectionName,
|
||||
@PathParam("uuid") final String uuid
|
||||
|
|
@ -82,7 +84,9 @@ public class Files {
|
|||
}
|
||||
|
||||
@GET
|
||||
@Path("/{path:^(?!uuid).+$}")
|
||||
//@Path("/{path:^(?!uuid).+$}")
|
||||
@Path("/{path:.+}")
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public Response getFile(
|
||||
@PathParam("content-section") final String sectionName,
|
||||
@PathParam("path") final String path
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package org.librecms.pages.models;
|
|||
import org.libreccm.l10n.GlobalizationHelper;
|
||||
import org.librecms.assets.BinaryAsset;
|
||||
import org.librecms.contentsection.AssetManager;
|
||||
import org.librecms.contentsection.Folder;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.transaction.Transactional;
|
||||
|
|
@ -46,6 +47,12 @@ public abstract class AbstractBinaryAssetModelBuilder<T extends BinaryAsset, M e
|
|||
super.addProperties(asset, model);
|
||||
model.setAssetPath(assetManager.getAssetPath(asset));
|
||||
model.setBinaryAssetUuid(asset.getUuid());
|
||||
model.setContentSection(
|
||||
assetManager
|
||||
.getAssetFolder(asset)
|
||||
.map(folder -> folder.getSection().getDisplayName())
|
||||
.orElse("")
|
||||
);
|
||||
model.setDescription(
|
||||
globalizationHelper.getValueFromLocalizedString(
|
||||
asset.getDescription()
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ public class BinaryAssetModel extends AbstractAssetModel {
|
|||
|
||||
private String binaryAssetUuid;
|
||||
|
||||
private String contentSection;
|
||||
|
||||
private String assetPath;
|
||||
|
||||
@Override
|
||||
|
|
@ -83,6 +85,14 @@ public class BinaryAssetModel extends AbstractAssetModel {
|
|||
this.binaryAssetUuid = binaryAssetUuid;
|
||||
}
|
||||
|
||||
public String getContentSection() {
|
||||
return contentSection;
|
||||
}
|
||||
|
||||
public void setContentSection(final String contentSection) {
|
||||
this.contentSection = contentSection;
|
||||
}
|
||||
|
||||
public String getAssetPath() {
|
||||
return assetPath;
|
||||
}
|
||||
|
|
@ -91,8 +101,4 @@ public class BinaryAssetModel extends AbstractAssetModel {
|
|||
this.assetPath = assetPath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue