Reputation: 37
Background: In one of my application am storing the datetimestamp in object store. Now that app is decommissioned and business team want the last stored datetimestamp in object store. By using cloudhub API i have got the below response from the objectstore api.
{ "binaryValue": "++Kn0AIB5+z4uQQBMjAyMi0wMS0zMVQxNToyODozMy4yN7b8rNmhAQHn7Pi5BGFwcGxpY2F0aW9uL2phdmE7IGNoYXJzZXQ9VVRGLbgAAAAAAAAAFw==", "keyId": "lastSuccessRunTime", "valueType": "BINARY" }
Also the business team want me to show the datetime stamp using the dataweave playground
I am trying to convert the binary value in a readable format using dataweave. I have tried available option up to my knowledge but nothing worked out.
Can some one help here?
Here is the DW code:
%dw 2.0
import * from dw::core::Binaries
output application/json
var
base64="++Kn0AIB5+z4uQQBMjAyMi0wMS0zMVQxNToyODozMy4yN7b8rNmhAQHn7Pi5BGFwcGxpY2F0aW9uL2phdmE7IGNoYXJzZXQ9VVRGLbgAAAAAAAAAFw=="
---
fromBase64(base64)
Upvotes: 0
Views: 412
Reputation: 932
you can try this code that is only specific solution to your question, but I insist follow this link https://help.mulesoft.com/s/article/How-to-decode-Object-Store-Key-value-in-Mule-4
%dw 2.0
import * from dw::core::Binaries
output application/json
---
do {
var decode= fromBase64(payload.binaryValue)
var data= decode[(decode find "2")[0] + 1 to (decode find ".")[0] + 3]
---
data
}
the output of this code is
"2022-01-31T15:28:33.27"
below is the snippet of the input/code/output
Note: The proper way is to use the Object Store 'Retrieve' operation if possible
Upvotes: 1