在 Groovy 脚本中打开图像

Open an image in Groovy Script

我正在测试网络服务 atm,我正在提取 Base64 格式的文件。

我已经设法隐藏文件并将它们保存到一个位置。

但是我希望直接打开文件,我正在处理 PDF 文件和图像,所以我认为浏览器是打开文件的最佳选择。

    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
import org.apache.commons.codec.binary.Base64;
Base64 coder = new Base64();

def filename = context.expand( '${DWG_OphalenBijlage (1)#Response#declare namespace b=\'http://schemas.datacontract.org/2004/07/Dynamics.Ax.Application\'; declare namespace ns1=\'http://www.XXXXXX.be/neptunus/moka/soconsult/getattachment\'; //ns1:MoKaGetAttachmentGetAttachmentResponse[1]/ns1:response[1]/b:MoKaSOAttachment[1]/b:FileType[1]}' )
def encodedString = context.expand( '${DWG_OphalenBijlage (1)#Response#declare namespace b=\'http://schemas.datacontract.org/2004/07/Dynamics.Ax.Application\'; declare namespace ns1=\'http://www.XXXXXXX.be/neptunus/moka/soconsult/getattachment\'; //ns1:MoKaGetAttachmentGetAttachmentResponse[1]/ns1:response[1]/b:MoKaSOAttachment[1]/b:DataFile[1]}' )
def decoded = encodedString.decodeBase64();
def f = new File(groovyUtils.projectPath + '/Bijlage1.' + filename);


f.delete();
f << decoded

log.info(groovyUtils.projectPath + '/Bijlage1.' + filename);

这已经保存了图像,有人可以建议我下一步应该做什么来自动打开文件吗?

你可以这样做:

java.awt.Desktop.desktop.open(f)

如果你是这个意思?