How to get full path when upload file choose desktop file workflow? | Community
Skip to main content
Level 3
December 23, 2018
Solved

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

  • December 23, 2018
  • 1 reply
  • 10005 views

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.

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Gaurav-Behl

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());

1 reply

Gaurav-Behl
Gaurav-BehlAccepted solution
Level 10
December 24, 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());

Level 2
May 31, 2021
Hi @gaurav-behl, can you suggest how to pick file using File API. Can you provide any example for that through which we can get absolute path of the file uploaded. Thank in advance!!