Jump to content
kitesoft2015@gmail.com

Handelling temprory files

Recommended Posts

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

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 by Andrea Magni

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×