Fórum
Deleting temp file after mail sent
O U, modificado 7 Anos atrás.
Deleting temp file after mail sent
Junior Member Postagens: 27 Data de Entrada: 22/02/11 Postagens Recentes
Hi,
I have a custom portlet which allow users to upload a file which is sent by email.
For that i'm uploading the file and storing it as a tmp file like this:
file = FileUtil.createTempFile(inputStream);
then i proceed to send my email with the file as attachment using the MailServiceUtil.
and now i want to delete the temps file but if I do this, I get a FileNotFoundException.
I suppose it is because the MessageBusUtil is not sending the mail right away but is using a separate thread instead which would make a lot of sense.
But i dont want to keep all the temp files otherwise my server will fill up real quick.
Have you ever face that issue ? If so what solution did you use ?
Thanks a lot,
I have a custom portlet which allow users to upload a file which is sent by email.
For that i'm uploading the file and storing it as a tmp file like this:
file = FileUtil.createTempFile(inputStream);
then i proceed to send my email with the file as attachment using the MailServiceUtil.
and now i want to delete the temps file but if I do this, I get a FileNotFoundException.
I suppose it is because the MessageBusUtil is not sending the mail right away but is using a separate thread instead which would make a lot of sense.
But i dont want to keep all the temp files otherwise my server will fill up real quick.
Have you ever face that issue ? If so what solution did you use ?
Thanks a lot,
Daniele Baggio, modificado 7 Anos atrás.
RE: Deleting temp file after mail sent (Resposta)
Expert Postagens: 336 Data de Entrada: 05/12/08 Postagens Recentes
Instead MailServiceUtil (which is based on asyncronous message bus) , you can try synchronous/blocking call to MailEngine.send() and delete file after it.
O U, modificado 7 Anos atrás.
RE: Deleting temp file after mail sent
Junior Member Postagens: 27 Data de Entrada: 22/02/11 Postagens Recentes
Perfect ! Thanks !