We have created a workflow to send approval mail to approver. The payload is jcr:content of a folder or a PDF.
After the coding, the behaviour is for:
A pdf : It generate right URL as http:///damadmin.html#/content/ab/cd/abc.pdf
A folder : It generate the wrong url as http:///damadmin.html#/content/folder-name/jcr:content
So, for folder, we have updated the code to change the payload as the folder-path instead of folder-path/jcr:content
for that we used,
WorkflowData wfData = wfSession.newWorkflowData("JCR_PATH", folder_node_path);
wfSession.updateWorkflowData(workItem.getWorkflow(), wfData);
After the code change, When a user modify any dam content like a pdf, the url is correct as http:///damadmin.html#/
but when the user modify a folder properties, the mail sent to approver has the wrong url as http:///
means /damadmin.html# is missing.
We need that the correct link should be added for both PDF and Folder.
Thanks in advance.
Issue is resolved.I am using CQ 5.5.
Sharing my experience.We don't need to change the payload. The payload can remain as jcr:content
We need to do two things:
Make sure the folder-path/jcr:content has the value in property jcr:title. It will be shown in content column of the inbox page.
For the folder link in inbox page, it must be as /content//jcr:content. The problem is because /damadmin.html# is not added before the url.
This problem is not coming for any Asset or Page.
Solution is:
You need add the following code in /libs/cq/workflow/components/inbox/list/json.jsp
A=>
Add private method
private String handleDamPathForFolder(Logger log, String payloadUrl, Session session, WorkItem wi)
{
try
{
if(isFolderNode(session, wi))
{
return ("/damadmin.html#"+payloadUrl);
}
}catch (Exception e)
{
log.error("Unable to handle path creation for work item: " + wi.getId(), e);
}
return payloadUrl;
}
We have to write the method isFolderNode which will return true if the node is a folder.
B=>Replace
JSONWriterUtil.write(writer, "payload", pathBuilder.getPath(wi),JSONWriterUtil.WriteMode.BOTH, xss);
by the follwoing
JSONWriterUtil.write(writer,"payload",handleDamPathForFolder(log,pathBuilder.getPath(wi), session, wi), JSONWriterUtil.WriteMode.BOTH, xss);
<br/>
Related
I am trying to send email in NestJs but seems to stuck at a weird error.
TypeError: Cannot destructure property 'templateName' of 'precompile(...)' as it is undefined.
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at new NodeError (node:internal/errors:363:5)
at ServerResponse.setHeader (node:_http_outgoing:573:11)
I am not sure what's going on the only solution I was able to find was to put ''./'' in front of the template names but I am not sure why would that work also it isn't even working in my case.
This is how i am trying to send it
this.mailService.sendEmail(
emailAddress,
[], // cc
[], // bcc
"Pretty Subject Line", // subject
"./verify-email", // template
{ // context
name: "tetsName",
verifyLink
}
);
templates folder is in root directory
Cannot set header error mostly occurs when you are sending a response after once you have sent a response. Take a look at the following code
//This does not work
res.send("This is a Response");
res.send("This is a second response");
If you are doing something like this, then it won't work. Try a logic that does all the tasks you want in one go or use may
res.write("This is a response"):
res.end();
For me,this is a template file path issue. Review your template.dir in your MailerModule config, and compare it to your project "dist" directory. if your template file path is "dist/templates/template.hbs" then your template.dir should be ${process.cwd()}/templates else if your dist directory is "dist/src/templates/template.hbs" ,which is depend on your compile configs. then your template.dir config should be join(__dirname, 'templates')
I've got a site that accepts file uploads which are sent as multipart/form-data within a POST request. To verify that the upload, which shows the filename afterwards, is secured against XSS I want to upload a file which contains HTML Tags in the filename.
This is actually harder than I expected. I can't create a file containing < on my filesystem (Windows). Also, I don't know a way to change the filename of the file input element inside the DOM before the upload (which is what I would do with normal/hidden inputs). So I thought about editing the POST body before it's uploaded, but I don't know how. Popular extensions (I recall Tamper Data, Tamper Dev) only let me change headers. I guess this is due to the plugin system of Chrome, which is the Browser I use.
So, what's the simplest way of manipulating the POST requests body? I could craft the entire request using cUrl, but I also need state, lots of additional parameters and session data etc. which gets quite complex... A simple way within the Browser would ne nice.
So, while this is not a perfect solution, it is at least a way to recreate and manipulate the form submit using FormData and fetch. It is not as generic as I'd like it to be, but it works in that case. Just use this code in the devtools to submit the form with the altered filename:
let formElement = document.querySelector('#idForm'); // get the form element
let oldForm = new FormData(formElement);
let newForm = new FormData;
// copy the FormData entry by entry
for (var pair of oldForm.entries()) {
console.log(pair[0]+': '+pair[1]);
if(typeof(pair[1]) == 'object' && pair[1].name) {
// alter the filename if it's a file
newForm.append(pair[0],pair[1],'yourNewFilename.txt');
} else {
newForm.append(pair[0],pair[1]);
}
}
// Log the new FormData
for (var pair of newForm.entries()) {
console.log(pair[0]+': ');
console.log(pair[1]);
}
// Submit it
fetch(formElement.action, {
method: formElement.method,
body: newForm
});
I'd still appreciate other approaches.
I want to save all png images that are loaded along with some webpage into a separate folder.
I am using below code with in Fiddler Script [CustomRules.js].
static function OnBeforeResponse(oSession: Session)
{
if(oSession.url.EndsWith(".png"))
{
oSession.SaveResponseBody();
}
//Actual content of OnBeforeResponse function.
}
Problem here is, I was unable to find any image got saved within Program files/Documents.
Where do “SaveResponseBody()” will save the HTTP Response Body?
Can we give our own custom folder?
My Fiddler version is (v4.4.5.6)
The default SaveResponseBody() method saves the files to your \Documents\Fiddler2\Captures\ folder. If you want to use a different name, use the overload that accepts a filename. You should check the Response's status code is 200 to ensure that you're not trying to save off HTTP/304 responses which won't contain a body. Also, rather than looking at the URL, you probably want to check the response's type.
So you end up with something like this:
if ((oSession.responseCode == 200) &&
oSession.oResponse.headers.ExistsAndContains("Content-Type", "image/png"))
{
SaveResponseBody("C:\\temp\\" + oSession.SuggestedFilename);
}
Note: The manual way of doing this would be to go to the QuickExec box below the Web Sessions list, type select png and hit Enter, then click File > Export > Selected Sessions > Raw Files.
It would be great if we could manage the titles of each image that we upload when uploading multiple images. This way I could select each image that I want to upload, title them, then hit the upload button. Right now one must either upload one by one or have all the selected images have the same title.
Kinda like Facebook or Panoramio where it's easy to manage the titles of the images before uploading.
This isn't natively supported in Fine Uploader at the moment, but I've opened up a feature request and tentatively scheduled it for the 3.7 milestone. In the meantime, you can certainly provide your own UI elements to allow users to provide alternate names for each upload-able item and pass these new names as a parameter. Server-side, you would have to parse this parameter and associate it with the uploaded item. Fine Uploader will have to adopt a parameter name that contains the user-supplied alternate filename anyway (and the server will have to be aware of this convention and parse this parameter), since we won't be able to change the value file input field sent along with the multipart encoded request.
use this:
var uploader = $('.uploader'),
titleBox = $('input[type=text]');
uploader.fineUploader({
request: {
endpoint: 'path/to/url'
},
formatFileName: function (name) {
var title = titleBox.val() + ' - ' + name + '';
titleBox.val('');
return title;
},
});
uploader.on('submit', function (event, id, name) {
uploader.fineUploader('setParams', {title: titleBox.val()}, id);
});
I work as software tester entry level and I was given a task to save my log files to the specific folder on my company website and this website only can be accessed internally by the company employees. So far I know how to save file onto the site, but how would I check which specific folder is already there before I save the file to it?
private void SaveLogsTogWeb(string file)
{
try
{
//create WebClient object
WebClient client = new WebClient();
client.Credentials = CredentialCache.DefaultCredentials;
client.UploadFile(#"http://myCompnay/MyProjects/TestLogs/" + file, "PUT", file);
client.Dispose();
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
}
Thanks in advance for the helps
Use this code:
if(!Directory.Exists({path}))
{
//create the directory
}
It checks to see if the directory doesn't exist. And if it doesn't then you can create it!
One way would be to put a dummy file in that folder (dummy.txt) and do an HTTP GET of the file. If you can successfully do that, you can then assume the folder exists (barring any virtual folders, etc.)