Skip to content

Commit b70ae90

Browse files
authored
formats/fromBase64: +outFile
1 parent 4c91a1f commit b70ae90

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

formats/fromBase64.yaml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ help:
1414
desc : Force the type of input between YAML or JSON file
1515
example : yaml
1616
mandatory: false
17+
- name : outFile
18+
desc : Force binary output to be written into a file
19+
example : my-bin.bin
20+
mandatory: false
1721

1822
todo:
1923
- Convert from Base64
@@ -30,9 +34,10 @@ jobs:
3034
- name : Convert from Base64
3135
check:
3236
in:
33-
file: isString.default(__)
34-
type: isString.oneOf(['yaml','json']).default('yaml')
35-
path: isString.default("@")
37+
file : isString.default(__)
38+
type : isString.oneOf(['yaml','json']).default('yaml')
39+
path : isString.default("@")
40+
outFile: isString.default(__)
3641
exec : |
3742
var data = ""
3843
@@ -46,7 +51,13 @@ jobs:
4651
4752
var _s = $$(data).get(args.path)
4853
if (isString(_s)) {
49-
print(af.fromBytes2String(af.fromBase64(_s)))
54+
if (isString(args.outFile)) {
55+
var _b = af.fromBase64(_s)
56+
var os = io.writeFileStream(args.outFile)
57+
ioStreamWriteBytes(os, _b)
58+
os.close()
59+
} else
60+
print(af.fromBytes2String(af.fromBase64(_s)))
5061
} else {
5162
printErr("No string detected on '" + args.path + "': " + af.toSLON(_s))
52-
}
63+
}

0 commit comments

Comments
 (0)