When trying to upload a large zip via multipart/form-data with httpbuilder-ng apache implementation version 0.16.1 i get
org.apache.http.ContentTooLongException: Content length is too long: 109370 at org.apache.http.entity.mime.MultipartFormEntity.getContent(MultipartFormEntity.java:103) at groovyx.net.http.ApacheEncoders.multipart(ApacheEncoders.java:74)
and that is Ok because the zip is rather large and there's no reason to wiggle it around buffers and ByteArray[Input|Output]Stream, question is how do i actually send the multipart to the connection's output stream? i tried to customize the encoder but the ToServer only exposes one method that accepts an InputStream which doesn't really work for me
Here is a snippet of what i was doing
configure {
request.uri = 'https://anypoint.mulesoft.com'
request.contentType = JSON[0]
request.encoder(MULTIPART_FORMDATA[0], ApacheEncoders.&multipart)
}
.post {
request.uri.path = '/cloudhub/api/v2/applications'
request.headers['X-ANYPNT-ENV-ID'] = eid
request.contentType = MULTIPART_FORMDATA[0]
request.body = multipart {
part('appInfoJson', JSON[0], '{"domain":"myDomain"}')
part('autoStart', 'true')
part(
'file',
'myLargeZip.zip',
BINARY[0], // or 'application/zip'
new File('/parent', 'myLargeZip.zip')
)
}
}