Allow export templates to return binary data #801
callumbwhyte
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Which component is this idea for?
Umbraco Commerce (Core)
Describe your idea
Currently the Export Templates feature is fairly rigid, only allowing text based file formats (like CSV) to be exported.
We often have a need for our clients to be able to export PDFs (for example). We generate these by first allowing Umbraco Commerce to render the Razor view for the Export Template, then passing the corresponding markup to something like Puppeteer to generate our PDF.
Frustratingly the controller that handles the export + zipping files if multiple are returned assumes every file will be a UTF-8 string.
It would be cool if this controller could be tweaked so each file receives a
Streamorbyte[]instead, opening the potential for returning other file formats.But how might we hook into this as developers? The export feature could broadcast a notification that could be subscribed to, like
ExportTemplateRenderingNotification. The event could include the string output of the template, and allow a result (Streamorbyte[]) to be set.I hacked together a fully working prototype of how this might work: https://github.com/callumbwhyte/umbraco-commerce-export For me this involved replacing the whole export controller with my own clone and tweaked logic, but this could be just a few lines of code in the Commerce Core...
Context
No response
Beta Was this translation helpful? Give feedback.
All reactions