Is it possible to open a blob without saving it to file

99 views Asked by At

My IDE is Delphi 10.3.

I have a Firebird 2.5 table, and the attachment field type is Binary Blob. Can I open this stored file (image, word, excel, pdf, txt, ...) without save to disk?

If this is not possible, I save the file, and after open or modified, how can I delete this file?

2

There are 2 answers

5
user13964273 On

If the software that you use to open the content allows opening anything other than file then yes. It may be a named or unnamed pipe, shared memory, OLE IStream interface, etc.

Otherwise it may be complicated but still possible.

In the worst case you can use ordinary temporary files, but do not forget to use the flags FILE_FLAG_DELETE_ON_CLOSE and FILE_ATTRIBUTE_TEMPORARY to avoid polluting file system.

0
Remy Lebeau On

Use your DataSet's CreateBlobStream() method to get a TStream to the blob data of an active record. You can the read the data from this stream and use it however you want.