How to get full path when upload file choose desktop file workflow?

naruk89179065

23-12-2018

Hi Team,

I done customization for startworkflow.jsp("/libs/cq/gui/components/authoring/workflow/startworkflow/startworkflow.jsp").

When click upload file choose option getting fakepath append filename,How to get full path directory need to send email attachment.

fakepath.PNG

fakepath1.PNG

I am not able  send file attached by using fakepath. error message : java.io.FileNotFoundException: C:\fakepath\testJcrcontent.txt(The system cannot find the path specified).

EmailAttachment attachment = new EmailAttachment();

  attachment.setPath("C:\fakepath\testJcrcontent.txt");

        attachment.setDisposition(EmailAttachment.ATTACHMENT);

        attachment.setDescription("Any Description");

        attachment.setName("Any name you can set");

Thanks

Kotireddy

Accepted Solutions (0)

Answers (1)

Answers (1)

Gaurav-Behl

MVP

24-12-2018

Pick the file using File API like   File file = new File(path_to_file); and then use file.getPath();

Alternatively, if you want to use a generic solution rather than a system dependent folder structure, try this -

File directory = new File("."); -- current WD for AEM, map the file path relative to AEM directory somewhere outside crx-quickstart

String path = directory.getCanonicalPath() + File.separator + LOCAL_FOLDER + File.separator;  -- File.separator would work both on Win & Linux

File file = new File(path + filename);

attachment.setPath(file.getPath());