AnsweredAssumed Answered

Serving binaries (PDF/PPT/GIF...)

Question asked by flefoll on May 4, 2009
Latest reply on Feb 7, 2012 by jhsu9
Hi

(Im' posting on French and English forum, and I will copy/paste answers for all).

The following webscript is fully working for serving XML content, but doesn't for binary content (like pdf/ppt or else..)

view.get.desc.xml
<webscript>
        <shortname>View</shortname>
        <description>View file</description>
        <url>/view/{path}</url>
        <authentication runas="admin">none</authentication>
        <transaction>required</transaction>
</webscript>

view.get.js
// 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;
}

view.get.xml.ftl
${requestFile.content}

What should I put in view.get.pdf.ftl or in view.get.ppt.ftl to have the same behaviour ?

MimetTypes are already extended on webscript-framework-application-context level.

Thanks in advance,

Francois.

Outcomes