SharpDocx icon indicating copy to clipboard operation
SharpDocx copied to clipboard

Split File & Stream usage

Open alphamax opened this issue 1 year ago • 4 comments

Keep DocumentBase but put on top DocumentFileBase and DocumentStreamBase. Adapt tests to generate also "Stream Version"

alphamax avatar Dec 10 '23 22:12 alphamax

Feel free to comment if I made any mistake :) I will fix

alphamax avatar Dec 11 '23 07:12 alphamax

Thank you! I'll have to test it a little bit and I'll let you know if I find anything.

egonl avatar Dec 12 '23 11:12 egonl

Is it possible to merge this PR ? I'm very interested by the Stream support.

vpellichero avatar Feb 26 '24 17:02 vpellichero

Using it for few weeks and seems to work :D

alphamax avatar Feb 26 '24 21:02 alphamax

@egonl how long will it take until this will be released as a package? Me and my Team really want this feature and would like to avoid forking the Repo.

btoepferDm avatar Apr 17 '24 13:04 btoepferDm

I'm a bit reluctant, because accepting a random stream containing code that will be executed is a huge security risk. What is your exact use case for which you need streams?

egonl avatar Apr 17 '24 15:04 egonl

@egonl our current Use case is that we want to be able to 1st: Cache the Templates in memory, to not do the IO work over and over again and then be able to use the same template multiple times in paralel, as they are used based on Messaging coming in inside a WebApi Application. So the current idea is, with this kind of API, we could Read all our Templates once, and then have pools for them, that the service instances can then grab and release, when needed.

If we want to do this currently, we'd have to Copy the Files and then pass the path to the new file into the DocumentFactory, this would likely lead to memory leaks, with randomly generated names atm tho, the way the caching is designed.

We would also be just as happy with having some sort of ByteArray as Input aswell, or being able to compile the Files seperately and being able to pass in the Compiled Document Template. We just want to not be coupled to the file system directly. Thank you for your Quick response :)

btoepferDm avatar Apr 17 '24 15:04 btoepferDm

Any news, thoughts or insights on this Topic?

btoepferDm avatar Apr 19 '24 14:04 btoepferDm

@btoepferDm Added support for view streams in #69. Could you give that a try?

egonl avatar Apr 22 '24 21:04 egonl

@btoepferDm Added support for view streams in #69. Could you give that a try?

Thank you very much, i will give it a try, hopefully today, latest tomorrow. Will get back to you with feedback, as soon as i have :)

btoepferDm avatar Apr 23 '24 07:04 btoepferDm

Implemented in #69, closing PR.

egonl avatar Apr 24 '24 19:04 egonl