在 Groovy 中将 Base64 字符串转换为图像文件
Convert Base64 String to Image file in Groovy
我检查了旧线程,但没有发现任何有用的信息。
我是 JD Edwards 开发人员,我们在 jde Orchestrator 中要求处理 base64 字符串。
任何人都可以帮助我并分享完整的代码吗?
我是 groovy 脚本的新手。
def base64str = 'R0lGODlhAwADAHAAACwAAAAAAwADAIHsHCT97KYAAAAAAAACBIQRBwUAOw==' // < base64 string with 3x3 gif inside
def filename = System.properties['user.home']+'/documents/my.gif' // < filename with path
// save decoded base64 bytes into file
new File(filename).bytes = base64str.decodeBase64()
因此,current user/ documents
文件夹中应该有一个新文件 my.gif
带有 3x3 像素图像(43 字节文件)
我检查了旧线程,但没有发现任何有用的信息。 我是 JD Edwards 开发人员,我们在 jde Orchestrator 中要求处理 base64 字符串。
任何人都可以帮助我并分享完整的代码吗?
我是 groovy 脚本的新手。
def base64str = 'R0lGODlhAwADAHAAACwAAAAAAwADAIHsHCT97KYAAAAAAAACBIQRBwUAOw==' // < base64 string with 3x3 gif inside
def filename = System.properties['user.home']+'/documents/my.gif' // < filename with path
// save decoded base64 bytes into file
new File(filename).bytes = base64str.decodeBase64()
因此,current user/ documents
文件夹中应该有一个新文件 my.gif
带有 3x3 像素图像(43 字节文件)