Forum Discussion

pb1's avatar
pb1
Contributor
5 years ago
Solved

Controlling FTPTestStep from groovy

Hello there

 

I am currently stuck trying to transfer files with the FTP-Step provided in SoapUI Pro. The files are generated before sending, and there may be a large amount of files to send.

 

The amount of files to send are determined after generation, I currently use a loop to iterate through all the files and add their information to the FTP-Step and then run it. Basically boiled down it's the following code:

new File(path).listFiles().each{
  ftpStep.setLocalPath(it.getPath())
  ftpStep.setFileName(it.getName())
  ftpStep.run(testRunner, context)
}

Sadly the transfer seems to fail every time, providing the following error:

Unable to upload the file: null

Looks to me like the testRunner gets confused and is unable to apply the filePath properly. testRunner and context are passed down from the invoked variables.

 

If I execute the FTP-Step without any modifications afterwards, it sends the previously configured file to the server without problems, so I can only assume that something with the run() function is not working properly.

 

I would appreciate any sort of help or workaround - but just confirming my problem would be sufficient for me to create a bug ticket

  • Thanks to the support for solving the problem:

     

    The ftpStep requires two additional method calls to properly transmit files, using the provided example in the OP the correct way to use the run method would be as follows:

     

    new File(path).listFiles().each{
      ftpStep.setLocalPath(it.getPath())
      ftpStep.setFileName(it.getName())
      ftpStep.prepare(testRunner, context)
      ftpStep.run(testRunner, context)
      ftpStep.finish(testRunner, context)
    }

10 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Is it possible to create archive file when multiple files, then do ftp in a single call?
    • pb1's avatar
      pb1
      Contributor

      Sadly I can not zip the files, they must be sent separately so the services behind the FTP-Server can properly use them.

      • nmrao's avatar
        nmrao
        Champion Level 3
        Post that unzip where there required.

        Additional benefit would be faster to ftp an archive than multiple files.