Jahia in English > Issues with file...

0 (0 Good)
0 (0 Bad)

Issues with file upload in live mode

by  namitgupta »  2012/12/03 09:14

Hi All,

I have requirement for accepting files from the user (Live mode). In order to achieve this functionality, i have created  a html form and an action handler. The code works fine in preview mode. However, it doesn't work in the live mode. PFB the code snippet for action handler:


public ActionResult doExecute(HttpServletRequest req,
RenderContext renderContext, Resource resource,
JCRSessionWrapper session, Map<String, List<String>> parameters,
URLResolver urlResolver) throws Exception {
objLogger.info("Inside method: Action Handler");
String strFirstName = getParameter(parameters,"firstname");
String strLastName = getParameter(parameters,"lastname");
objLogger.info("File Path: "+renderContext.getUser().getLocalPath());
JCRNodeWrapper objNodeWrapper = session.getNode(renderContext.getUser().getLocalPath() + "/files");
objLogger.info("Node Wrapper" + objNodeWrapper.getPath());
FileUpload fileUpload = (FileUpload) req.getAttribute(FileUpload.FILEUPLOAD_ATTRIBUTE);
DiskFileItem inputFile = fileUpload.getFileItems().get("fileField");
objNodeWrapper.uploadFile(inputFile.getName(), inputFile.getInputStream(), inputFile.getContentType());
objLogger.info("First Name:"+strFirstName);
objLogger.info("Last Name:"+strLastName);
objLogger.info("File Name: "+inputFile.getContentType());
objLogger.info("Node Name: "+renderContext.getUser().getLocalPath());
objLogger.info("WebDAV URL: "+objNodeWrapper.getWebdavUrl());
        objLogger.info("Exiting method: Action Handler");
        return new ActionResult(HttpServletResponse.SC_ACCEPTED,
new JSONObject());
Upon analyzing the issue, I found that the handler fails at "JCRNodeWrapper objNodeWrapper = session.getNode(renderContext.getUser().getLocalPath() + "/files");".
Please let me know your thoughts on this.



Number of messages  36
Registration date
0 (0 Good)
0 (0 Bad)

Re: Issues with file upload in live mode

by  dgriffon »  2013/12/16 13:50


can you check that the /files node is present in live under the user nodepath ?

if not, it means that the node has not be published yet. 

You have to publish it once before using it in live.



David Griffon (dgriffon)

Number of messages  76
Registration date

Get in touch

Whether you are a current user or if you are just evaluating Jahia, we are here to help.

Contact us

Share this page