Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Temporary files without saving to HDD

Tags:

c#

.net

abcpdf

Here is my case:

I'm using ABCPDF to generate a HTML document from a .DOCX file that I need to show on the web. When you export to HTML from ABCPDF you generate a HTML and a folder with support files (.css, .js, .png)

Now these HTML files may contain quite sensitive data so I immediately after generating the files, I move them to a password-protected .zip file (from which I fetch them later)

The problem is, that this leaves the files unencrypted on the HDD for a few seconds and even longer if I'm (for some reason) unable to delete them at once.

I'd like suggestions for another way of doing this. I've looked in to a ram drive, but I'm not happy with installing such drivers on my servers. (AND the RAM drive would still be accessible from the OS)

The cause of the problem here might be that ABCPDF can only export HTML as files (since its multiple files) and not as a stream.

Any ideas?

I'm using .NET 4.6.x and c#

like image 535
Henrik Clausen Avatar asked Oct 14 '25 03:10

Henrik Clausen


1 Answers

Since all your files except the .HTML are anonymous, you can use the suggested way of writing the HTML to a stream. Only all other files will be stored to the file system.

http://www.websupergoo.com/helppdfnet/source/5-abcpdf/doc/1-methods/save.htm

When saving to a Stream the format can be indicated using a Doc.SaveOptions.FileExtension property such as ".htm" or ".xps". For HTML you must provide a sensible value for the Doc.SaveOptions.Folder property.

http://www.websupergoo.com/helppdfnet/source/5-abcpdf/xsaveoptions/2-properties/folder.htm

This property specifies the folder where to store additional data such as images and fonts. it is only used when exporting documents to HTML. It is ignored otherwise.

For a start, try using a simple MemoryStream to hold the sensitive data. If you get large files or high traffic, open an encrypted stream to a file on your system.

like image 73
Alex AIT Avatar answered Oct 18 '25 17:10

Alex AIT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!