You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The StreamWriter feature in Excelize is great for handling large XLSX file generation. Currently, temporary files are created using Golang's os.CreateTemp, as seen in stream.go#L740.
In some cases, relying on os.CreateTemp is not flexible enough. Specifically, there are scenarios where it's preferable to direct these temporary files to different or dynamically determined storage locations based on the request context. This restriction can limit the usage of StreamWriter in more complex environments.
I propose adding an option in StreamWriter to allow users to provide a custom temporary file creation method. This would follow the options pattern, maintaining the current behavior as the default. The user would be able to specify their own TempFileFactory, allowing for dynamic control over the temporary file path.
Thanks for your suggestion. The temporary file not only used in stream writer, but also in stream reader (rows iterator), you can set TMPDIR environment variable for excelize application in the runtime to changed temporary file location, does this make sense? If we decide expose this for the user, add new fields TempDir in the Options data type would be better.
Using the TMPDIR environment makes sense if it's fine to have all the same temporary file under the same folder.
But sometimes there are needs to put the temporary files under different places for different context.
For example, use different mount/harddisk for different clients or utillizing different disks based on their free-space at the moment.
Management of this logic is impossible throguh env variable since the variable is shared between threads.
Adding a new field TempDir as optional data is a great option as well. (Less flexable but easier)
The StreamWriter feature in Excelize is great for handling large XLSX file generation. Currently, temporary files are created using Golang's os.CreateTemp, as seen in stream.go#L740.
In some cases, relying on os.CreateTemp is not flexible enough. Specifically, there are scenarios where it's preferable to direct these temporary files to different or dynamically determined storage locations based on the request context. This restriction can limit the usage of StreamWriter in more complex environments.
I propose adding an option in StreamWriter to allow users to provide a custom temporary file creation method. This would follow the options pattern, maintaining the current behavior as the default. The user would be able to specify their own TempFileFactory, allowing for dynamic control over the temporary file path.
For example:
I have no problem to contribue this solution for the library if there is an agreement on a solution.
The text was updated successfully, but these errors were encountered: