Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
545 views
in CompleteFTP by (120 points)
I would like to send a single email containing a list of files uploaded during a session.  With 'upload' I get one per file, with 'log out' I get nothing.

1 Answer

0 votes
by (51.6k points)

You can do this using two process triggers of type JSS.  The first one triggers for each uploaded files and stores the path of the uploaded file in memory.  The second one triggers on log-out and sends the email containing the list of files.

Process trigger 1:

  • Name: Remember uploads
  • Events: Upload file
  • Type: JSS script
  • Script below:
if (!system.user.tags.get("uploads"))
    system.user.tags.set("uploads", "[]");
var uploads = JSON.parse(system.user.tags.get("uploads"));
uploads.push(event.virtualPath);
system.user.tags.set("uploads", JSON.stringify(uploads));

Process trigger 2:

  • Name: Email uploads on log out
  • Events: Log out
  • Type: JSS script
  • Script below:
var uploads = system.user.tags.get("uploads");
if (uploads) {
    uploads = JSON.parse(uploads);
    
    var message = "The following files were uploaded:\r\n";
    for (var i in uploads)
        message += "- " + uploads[i] + "\r\n";

    mail.smtp.server = "smtp.gmail.com";
    mail.smtp.port = 587;
    mail.smtp.userName = "my.account@gmail.com";
    mail.smtp.password = "my.password";
    mail.smtp.enableSSL = true;

    mail.send("sender@test.com", "recipient@test.com", "Files uploaded", message);
}

Make sure you change the SMTP settings to match your mail server and account.


 

by (100 points)
This is what I am seeing in the diagnostic logs when running the above process triggers sequentially:

2024-05-15 14:59:21,758 ERROR JSS [Server.1] Javascript error: Property 'push' of object is not a function
2024-05-15 14:59:21,759 ERROR JSS [Server.1]    at Remember Uploads - SWH:3:1

Note: It appears that the first process trigger is failing due to the 'uploads. Push' line.

Please advise
by (51.6k points)
This should be fixed in version 23.1.2, which has just been released.
by (100 points)
That bug is fixed in the latest build, and according to the Diagnostics log, the 'Remember Uploads' - Process Trigger 1 - is working properly. However, Process Trigger 2 is not showing the in the Diagnostics log, and I am not receiving an email with the remembered uploads.

Can you please verify that this is working in the latest build?
by (162k points)
For this you'll need to open an issue (see our support page) and submit a debug log file from the period when it is supposed to be running.

Categories

...