Storing Multi-Line Strings in Params¶
Due to command line limitations, it can be difficult to store multi-line strings in Params from DRPCLI because newlines and certain characters are interpreted as end of line markers.
Solution¶
This KB provides two alternatives depending on your use case.
Option 1: Use JQ to convert file into a string¶
For most use cases, simply processing the input through [jq]{.title-ref} provides sufficient protection. This has the advantage of being easily rendered in the UX.
With a file:
With a variable:
Option 2: Use base64 to encode the file into a string¶
For use cases where file formatting is very specific, using base64 encoding is safer. The downside of this approach is that it requires decoding ([base64 -d]{.title-ref}) before the value can be used.
This has the advantage of not being human readable without decoding. While this is NOT a security benefit, it does provide a layer of obfuscation. If you need secure storage, use the Secure flag!
With a file:
Note
Some versions of base64 include a flag that eliminates n; however,
the tr
approach has a broader support across different
operating systems.
Additional Information¶
Additional resources and information related to this Knowledge Base article.
See Also¶
It's important to understand the different Param types and make sure you are using the correct one.
Versions¶
All
Keywords¶
multi-line, string, jq, base64