RealNetworks
11 years agoOccasional Contributor
Attaching part of the file
Hi,
If someone could help me or has some kind of advice I would very appreciate it.
I need to create test request for REST service that uploads a file. File size can be large and in that case file is split into few chunks and upload REST service needs to be called few consecutive times. After splitting file, file chunks are represented as an byte arrays. Is there a way to attach byte array into REST test request? I know that it is possible to attach file with "attachFile()" method that takes file an an argument. So currently my Groovy script looks like this:
Is there a simpler way of doing this that does not include creation of the temporary file out of the byte array?
Thank you in advance for your answers.
If someone could help me or has some kind of advice I would very appreciate it.
I need to create test request for REST service that uploads a file. File size can be large and in that case file is split into few chunks and upload REST service needs to be called few consecutive times. After splitting file, file chunks are represented as an byte arrays. Is there a way to attach byte array into REST test request? I know that it is possible to attach file with "attachFile()" method that takes file an an argument. So currently my Groovy script looks like this:
def outputFile = null
def request = testRunner.testCase.getTestStepByName("Upload test request").testRequest
def tmpOutputFile = new File(outputFilePath).withOutputStream {
it.write bytes // bytes is an byte array that contains file chunk
}
outputFile = new File (outputFilePath);
def attachment = request.attachFile(outputFile, true)
Is there a simpler way of doing this that does not include creation of the temporary file out of the byte array?
Thank you in advance for your answers.