Question
· May 20

%Stream files do not get purged from the <namespace>/stream/ folder on the system disk

As the title says, I've noticed that files that gets saved to the disk where the database lies (.DAT file) in the stream directory, does not get purged. Is this expected and do we need to create our own schedule task to clean this folder up?

I could only find old answers that say this, however I find it a bit odd if that is the case because they are considered temporary files. Perhaps I do not handle the streams correctly in the code?

set fileToDisk = ##class(%Stream.FileBinary).%New()
set fileToDisk.Filename = fileDestinationPath
set copyStatus = fileToDisk.CopyFromAndSave(response.Data)
Product version: IRIS 2024.2
$ZV: IRIS for UNIX (Ubuntu Server LTS for ARM64) 2024.1.2 (Build 398U) Thu Oct 3 2024 13:42:05 EDT
Discussion (7)3
Log in or sign up to continue

https://docs.intersystems.com/irisforhealthlatest/csp/documatic/%25CSP.D...

Am I missing something? I am saving the data inside response.Data to the fileDestinationPath, which works but it also saves to the database stream folder and never gets purged.

I understand I have to use TmpBinary instead but what is the point of keeping a copy in the stream folder when the code has finished executing? the files are also not named in a way that makes them recognizable other than their extension and file size.

Basically the file is saved to both the location I set at fileDestinationPath and the stream folder where the database file resides.

So I've created a custom message structure for stuffing PDFs extracted from HL7 messages into a COLD feed. I've been using %Stream.FileBinary as the object type for the stream property in the class. I hadn't given much thought to the fact that those streams might hang around after a message purge, so I went back and modified the class to use %Stream.TmpBinary. I mean, that seems to make sense, right?

Except that with %Stream.TmpBinary, the stream goes away as soon as the message leaves the business process, and no file gets written by the operation. Oops.

So I'm back to using %Stream.FileBinary ... I would hope that the Interoperability message purge task would "do the right thing" and delete the stream since the message object extends Ens.Request, but I suppose I should do some experimentin' 😉