This would seem to be a simple problem, but I haven't been able to find out why I cannot
successfully decode a HTML stream with embedded XML.
This is the base64 string:
LS1ib3VuZGFyeQ0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJNb3ZlRGV0ZWN0aW9uLnhtbCI7IGZpbGVuYW1lPSJNb3ZlRGV0ZWN0aW9uLnhtbCINCkNvbnRlbnQtVHlwZTogYXBwbGljYXRpb24veG1sDQpDb250ZW50LUxlbmd0aDogNTQ5DQoNCjw/eG1sIHZlcnNpb249IjEuMCIgZW5jb2Rpbmc9IlVURi04Ij8+DQo8RXZlbnROb3RpZmljYXRpb25BbGVydCB2ZXJzaW9uPSIyLjAiIHhtbG5zPSJodHRwOi8vd3d3Lmhpa3Zpc2lvbi5jb20vdmVyMjAvWE1MU2NoZW1hIj4NCjxpcEFkZHJlc3M+MTAuODguMS4xOTY8L2lwQWRkcmVzcz4NCjxwb3J0Tm8+Mzk1MDE8L3BvcnRObz4NCjxwcm90b2NvbD5IVFRQPC9wcm90b2NvbD4NCjxtYWNBZGRyZXNzPjY0OjMxOjM5OjMwOmNjOmU5PC9tYWNBZGRyZXNzPg0KPGNoYW5uZWxJRD4xPC9jaGFubmVsSUQ+DQo8ZGF0ZVRpbWU+MjAyNC0wMS0xNVQxODo0NDo1OS0wNjowMDwvZGF0ZVRpbWU+DQo8YWN0aXZlUG9zdENvdW50PjE8L2FjdGl2ZVBvc3RDb3VudD4NCjxldmVudFR5cGU+Vk1EPC9ldmVudFR5cGU+DQo8ZXZlbnRTdGF0ZT5hY3RpdmU8L2V2ZW50U3RhdGU+DQo8ZXZlbnREZXNjcmlwdGlvbj5Nb3Rpb24gYWxhcm08L2V2ZW50RGVzY3JpcHRpb24+DQo8Y2hhbm5lbE5hbWU+Q2FtZXJhIDAxPC9jaGFubmVsTmFtZT4NCjwvRXZlbnROb3RpZmljYXRpb25BbGVydD4NCg0KLS1ib3VuZGFyeS0tDQo=
This is the function I used:
String decode64(String raw) {
def decodedBytes = raw.decodeBase64()
def decoded = new String(decodedBytes, "UTF-8")
return decoded
}
The decoded base64 should be this:
--boundary
Content-Disposition: form-data; name="MoveDetection.xml"; filename="MoveDetection.xml"
Content-Type: application/xml
Content-Length: 549
<EventNotificationAlert version="2.0" xlmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>10.88.1.196</ipAddress>
<portNo>39501</portNo>
<protocol>HTTP</protocol>
... more of the same ...
--boundary--
But what I get is everything decoded but missing all text in < > brackets:
--boundary Content-Disposition: form-data; name="MoveDetection.xml"; filename="MoveDetection.xml" Content-Type: application/xml Content-Length: 549 10.88.1.196 39501 HTTP 64:31:39:30:cc:e9 1 2024-01-15T19:07:22-06:00 1 VMD active Motion alarm Camera 01 --boundary--
Decoding the base64 stream in another application results in the proper text.
Any ideas what is wrong here?
Any help would be greatly appreciated.
Regards,
Gene