Page 1 of 1

XPRIM_HttpRequest

Posted: Wed Jul 03, 2019 12:22 pm
by soa
Hi

I have the following code fragment

#TempFile.CreateTemporaryFile

#Request.Response.AsFile Autodelete(True) Path(#TempFile)

#FileStream.Path := #TempFile

Which all works beautifully but I've noticed my \tmp folder is filling up with files like

QACXCAYX2M
QACXCR5FHZ
QACXC1W4KL
QACXDCA0W2
QACXDKR36C

Which contain the json I'm getting back in my response

Isn't the Autodelete supposed to take care of this or have I missed something?

Re: XPRIM_HttpRequest

Posted: Wed Jul 03, 2019 12:48 pm
by tsupartono
The original code I provided was not correct - my apology for that.

Providing the path when calling AsFile is the culprit as that stops the auto delete from doing its job.

Can you change the #TempFile type to #PRIM_ALPH

Code: Select all

Define_Com Class(#PRIM_ALPH) Name(#TempFile)
And change the AsFile invocation like so:

Code: Select all

#Request.Response.AsFile Autodelete(True) Result(#TempFile)
That should delete the file when #Request goes out of scope.
Take special care when you are using the file as an output of a web service - as that require to file to live beyond the normal runtime scope.