<webscript>
<shortname>View</shortname>
<description>View file</description>
<url>/view/{path}</url>
<authentication runas="admin">none</authentication>
<transaction>required</transaction>
</webscript>
// locate folder by path
// NOTE: only supports path beneath company home, not from root
logger.log("Start View script. Requested resource : " + url.extension);
var alfrescoCompanyHomeFolder = "Company Home";
logger.log("Alfresco company folder name : " + alfrescoCompanyHomeFolder);
var baseFolderPath = "My_Folder";
logger.log("Base folder path : " + baseFolderPath);
var completePath = (alfrescoCompanyHomeFolder + "/" + baseFolderPath + "/" + url.extension).replace(new RegExp("_SPACE_","g"), " ")
;
logger.log("Real requested path : " + completePath);
var requestFile = roothome.childByNamePath(completePath);
if (requestFile == undefined) {
logger.log("Requested resource is not found");
status.code = 404;
status.message = "Requested resource is not found";
status.redirect = true;
} else if (requestFile.isContainer) {
logger.log("Browsing is not allowed");
status.code = 403;
status.message = "Browsing is not allowed";
status.redirect = true;
} else {
logger.log("Rendering selected file");
model.requestFile = requestFile;
}
${requestFile.content}
<webscript kind="org.alfresco.repository.content.stream">
<shortname>Webview rendering</shortname>
<description>Render selected file
</description>
<url>/view/{path}</url>
<format default="">argument</format>
<authentication runas="admin">none</authentication>
<transaction>required</transaction>
</webscript>
// locate folder by path
// NOTE: only supports path beneath company home, not from root
logger.log("Start webview script. Requested resource : " + url.extension);
var alfrescoCompanyHomeFolder = "Company Home";
logger.log("Alfresco company folder name : " + alfrescoCompanyHomeFolder);
var baseFolderPath = "My_Folder";
logger.log("Base folder path : " + baseFolderPath);
var completePath = (alfrescoCompanyHomeFolder + "/" + baseFolderPath + "/" + url.extension).replace(new RegExp("_SPACE_","g")
, " ");
logger.log("Real requested path : " + completePath);
var requestFile = roothome.childByNamePath(completePath);
if (requestFile == undefined) {
logger.log("Requested resource is not found");
status.code = 404;
status.message = "Requested resource is not found";
status.redirect = true;
} else if (requestFile.isContainer) {
logger.log("Browsing is not allowed");
status.code = 403;
status.message = "Browsing is not allowed";
status.redirect = true;
} else {
logger.log("Rendering selected file");
model.contentNode = requestFile;
}
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.