kitesoft2015@gmail.com 1 Posted February 25, 2019 (edited) hi has Mars any solution to handle temporary or cached files that generated by api with unique name and delete them after a while? thanks in advance Edited February 25, 2019 by kitesoft2015@gmail.com Share this post Link to post
kitesoft2015@gmail.com 1 Posted February 27, 2019 I have using "Demos/ContentTypes" approach to response a temporary pdf file [GET, Path('/pdf'), Produces('application/pdf')] function PdfDocument: TStream; I want to delete temporary(PDF) file after response dispatched. any idea please Share this post Link to post
Andrea Magni 75 Posted February 28, 2019 (edited) Hi @kitesoft2015@gmail.com, you can have a method, in your resource, marked with AfterInvoke attribute. This method will be called after the actual response has been sent to the client so I think it would be a good moment to delete the file. You may store the temp file name in a field of your resource. In theory for temporary files you may ask the operating system to provide a proper file name (and path) so that the OS knows it can clean those files when needed. I guess your question comes because you actually don't want that file to stay on the file system longer than needed. Also consider you may serve a stream (without passing from the disk file), if you can. Sincerely, Andrea Edited February 28, 2019 by Andrea Magni Share this post Link to post