0

I'm testing web services atm and I'm pulling files in a Base64 format.

I've managed to covert the files and save them to a location.

However I'd like the files to open directly, I'm working with PDF files and images so I think a browser would be the best to open the files in.

    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);

This saves the image now can annybody suggest me what I should do next to open the file automaticly?

  • 1
    What do you mean open image in groovy script? Any favourite tool in which you want to open? – Rao Mar 29 '17 at 15:23

1 Answers1

1

You can do:

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

If that's what you mean?

tim_yates
  • 167,322
  • 27
  • 342
  • 338