I have searched the forums and found a few threads, but nothing specific to my challenge.
I am reading a SQL table column called “filebytes” which has a datatype of “image”.This “filebytes” column contains a binary encoded file (a pdf in this case). I have extracted the value (see below) as a string, written it to xml and transported the xml over the network. I am stuck where it needs to be decoded back to a human readable file.
Initially I tried using Base64, but then only realised base64 only works with ASCII and not binary, so the file ended up as corrupt once decoded.
I am not sure how to decode it, since my only “input” at the moment is this string, and I am not sure how to properly convert the string to a byte[] and do the decoding.
Any help is greatly appreciated.
Below is the binary data as it appears in SQL, which is extracted as a string:
0x255044462D312E350D0A25B5B5B5B50D0A312030206F626A0D0A3C3C2F547970652F436174616C6F672F50616765732032203020522F4C616E6728656E2D474229202F53747275637454726565526F6F742038203020522F4D61726B496E666F3C3C2F4D61726B656420747275653E3E3E3E0D0A656E646F626A0D0A322030206F626A0D0A3C3C2F547970652F50616765732F436F756E7420312F4B6964735B2033203020525D203E3E0D0A656E646F626A0D0A332030206F626A0D0A3C3C2F547970652F506167652F506172656E742032203020522F5265736F75726365733C3C2F466F6E743C3C2F46312035203020523E3E2F50726F635365745B2F5044462F546578742F496D616765422F496D616765432F496D616765495D203E3E2F4D65646961426F785B20302030203834312E3932203539352E33325D202F436F6E74656E74732034203020522F47726F75703C3C2F547970652F47726F75702F532F5472616E73706172656E63792F43532F4465766963655247423E3E2F546162732F532F537472756374506172656E747320303E3E0D0A656E646F626A0D0A342030206F626A0D0A3C3C2F46696C7465722F466C6174654465636F64652F4C656E677468203133323E3E0D0A73747265616D0D0A789C758EBB0AC2401444FB0BF71FA68CCD3ECC4A56098164B3BE6045F076216DACFCFFD6A4106E230353CD1C0EEC136D6B4BBA8D705D87614C1884C99E3D42842C4C1E6E8D47B34768A2A9211F2687F75617A6A992FC92137A913E5D4B7EC86E86DC99F28AD950BFFF211C4DA81563AAA0A6C825014AC72B1DEDE082897F015F013F293F0D0A656E6473747265616D0D0A656E646F626A0D0A352030206F626A0D0A3C3C2F547970652F466F6E742F537562747970652F54727565547970652F4E616D652F46312F42617365466F6E742F417269616C2F456E636F64696E672F57696E416E7369456E636F64696E672F466F6E7444657363726970746F722036203020522F4669727374436861722033322F4C617374436861722038342F576964746873203135203020523E3E0D0A656E646F626A0D0A362030206F626A0D0A3C3C2F547970652F466F6E7444657363726970746F722F466F6E744E616D652F417269616C2F466C6167732033322F4974616C6963416E676C6520302F417363656E74203930352F44657363656E74202D3231302F436170486569676874203732382F4176675769647468203434312F4D6178576964746820323636352F466F6E74576569676874203430302F58486569676874203235302F4C656164696E672033332F5374656D562034342F466F6E7442426F785B202D363635202D3231302032303030203732385D203E3E0D0A656E646F626A0D0A372030206F626A0D0A3C3C2F417574686F7228526F7279204861696768292F43726561746F7228FEFF004D006900630072006F0073006F0066007400AE0020004F0066006600690063006500200057006F0072006400200032003000300037292F4372656174696F6E4461746528443A323031323032303730383535333529202F4D6F644461746528443A323031323032303730383535333529202F50726F647563657228FEFF004D006900630072006F0073006F0066007400AE0020004F0066006600690063006500200057006F0072006400200032003000300037293E3E0D0A656E646F626A0D0A31332030206F626A0D0A3C3C2F547970652F4F626A53746D2F4E20362F46697273742033362F46696C7465722F466C6174654465636F64652F4C656E677468203135363E3E0D0A73747265616D0D0A789C6D8F4D0A83400C85F78277783798445B3A05F102820CEA4E5C14095DB596E908F5F69D58A185BACADF97F7126610F880FC08269C08161C9333D8C64E868C2C8AC2389D121AD31A67AA1E34C0B82B72ED95659AEC20BC87D88D68650C2BA4F68D1E10C3808DEB96879836F8790C9D1769A6291877F1725FCB789C8AE8367DD67E86B5BC42250B7893AAE7DBB3D717B3AFC39F6D9ABC01665C3E810D0A656E6473747265616D0D0A656E646F626A0D0A31352030206F626A0D0A5B2032373820302030203020302030203020302030203020302030203020302030203020302030203020302030203020302030203020302032373820302030203020302030203020363637203020373232203020363637203020302037323220302030203020302038333320373232203020302030203020363637203631315D200D0A656E646F626A0D0A31362030206F626A0D0A3C3C2F547970652F585265662F53697A652031362F575B2031203420325D202F526F6F742031203020522F496E666F2037203020522F49445B3C31354437323535423842423230323433414234314331454541443545433639443E3C31354437323535423842423230323433414234314331454541443545433639443E5D202F46696C7465722F466C6174654465636F64652F4C656E6774682036363E3E0D0A73747265616D0D0A789C63600082FFFF1981A420030388AA81505BC014E30230C59407A6987920D41BA00850092F0333846281504C100A2AC70A54C9720DC66304F258813C00F4B307760D0A656E6473747265616D0D0A656E646F626A0D0A787265660D0A302031370D0A3030303030303030303820363535333520660D0A30303030303030303137203030303030206E0D0A30303030303030313234203030303030206E0D0A30303030303030313830203030303030206E0D0A30303030303030343136203030303030206E0D0A30303030303030363232203030303030206E0D0A30303030303030373830203030303030206E0D0A30303030303031303034203030303030206E0D0A3030303030303030303920363535333520660D0A3030303030303030313020363535333520660D0A3030303030303030313120363535333520660D0A3030303030303030313220363535333520660D0A3030303030303030313320363535333520660D0A3030303030303030313420363535333520660D0A3030303030303030303020363535333520660D0A30303030303031343934203030303030206E0D0A30303030303031363433203030303030206E0D0A747261696C65720D0A3C3C2F53697A652031372F526F6F742031203020522F496E666F2037203020522F49445B3C31354437323535423842423230323433414234314331454541443545433639443E3C31354437323535423842423230323433414234314331454541443545433639443E5D203E3E0D0A7374617274787265660D0A313930380D0A2525454F460D0A787265660D0A3020300D0A747261696C65720D0A3C3C2F53697A652031372F526F6F742031203020522F496E666F2037203020522F49445B3C31354437323535423842423230323433414234314331454541443545433639443E3C31354437323535423842423230323433414234314331454541443545433639443E5D202F5072657620313930382F5852656653746D20313634333E3E0D0A7374617274787265660D0A323430330D0A2525454F46
Thanks in advance.
The file contains
TEST : ATTACHMENT