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
Solved! Go to Solution.
Views
Replies
Total Likes
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());
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());
Views
Replies
Total Likes
Sorry sushmapoojitha, I'm unable to understand the question. Did this pseudocode not work? I'm not sure if you're trying to achieve that in a dialog or a component using what technology? Here are a couple of examples that might help -
https://docs.oracle.com/javaee/6/tutorial/doc/glraq.html ,
https://github.com/adobe/aem-upload#uploading-files ,
https://www.initialyze.com/blog/2019/03/how-to-handle-file-upload-in-aem/ ,
Remember to use MultipartRequest - https://stackoverflow.com/questions/16958448/what-is-http-multipart-request
thanks
Views
Replies
Total Likes
'
Views
Replies
Total Likes
Hi @Gaurav-Behl, actually I am uploading a file using js script
" $("#fileupload").click(function(){
var input = document.createElement("input");
input.type = "file";
input.id="myfile";
input.name="myfile";
input.onchange = _ => {
// you can use this method to get file and perform respective operations
let uploadedFile = input.files;
//document.getElementById('target_div').appendChild(input);
console.log(uploadedFile[0]);
console.log(uploadedFile[0].name);
};
input.click();
});"
on button click. I need to send the absolute path of this file to my servlet which on getting path will read the file and submit data. But here i am not able to get absolute path for the uploaded file. Is there any way to get the absolute path as I read in many places that due to security reasons some browsers don't support it. Is there any way for this? Thanks in advance!
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies