File upload as attachment

Hello,

I am trying to build an app that has the user upload a file which is then automatically sent to a specific email. How do I set up my codeless logic to grab the name of the uploaded file so that I can send it as an attachment to an email?

Thanks,
Daniel

When you upload a file, you point the name (target file path) where you want to save it. It’s some directory in the Files. So being known about the path you can extract the file name, or use the path without modifications as an attachment.

E.g. you can also create an afterUpload handler, where you take the target path (from handler parameters) and process it in further logic.

Thank you for the quick reply Oleg,

I’m using this logic to extract the file name (since the requirements for “attachments” are very specific), but I’m running into some errors whenever the file name has a space in it. Is there a better way to extract the file path to use for the attachment?

Best,
Daniel

Hi @DANIEL_SHAPIRO

Thanks for sharing your experience!
Saving to the DB and then retrieving it just to compose a URL is not a good way, I would recommend you build a valid path right after you uploaded a file.

I’ve created a ticket to investigate the issue with the requirements of the attachment

Regards,
Vlad

I think I have found the solution.

You were right about not saving to the database. I just created an object from the uploaded files and converted the object to text. From there, the same logic of looking for the file path starting from “images/” works. Thank you for the help.

Best,
Daniel

1 Like