2

I am trying to forward a large file pulled as an input stream to another service using spring's resttemplate. I have followed the answer given by @artbristol in this topic: How to forward large files with RestTemplate?

And it looks like it is setting the body of the request properly (grabbing the request with charlesproxy). The problem is that I have not set the headers correctly since I believe I need to set the content-type as multipart/formdata which I tried by adding this in the callback:

request.getHeaders().setContentType(
                new MediaType("multipart", "form-data"));

But in the http headers I am still missing the boundary, not sure how to set that and I am sure I am probably missing some other settings.

Community
  • 1
  • 1
kpeng
  • 81
  • 1
  • 9

2 Answers2

0

So I was able to figure this out. Basically I needed to create a Spring message converter that will take in the input stream and write out to the body. I also basically have to use the Form Message Converter to write out the response body as well.

So in the restTemplate I call an add message converter to add new input stream message converter. In the call back I create a multivaluemap that takes in a string and inputstream and wrap that around an HttpEntity. Then I create a new instance of the Form Message converter and call write, passing in request, and the mutlivaluemap.

kpeng
  • 81
  • 1
  • 9
0

It looks like the issue is that I did not include the path to htrace-core.jar in the spark class path: spark-shell --driver-class-path /opt/cloudera/parcels/CDH/lib/hbase/hbase-server.jar:/opt/cloudera/parcels/CDH/lib/hbase/hbase-protocol.jar:/opt/cloudera/parcels/CDH/lib/hbase/hbase-hadoop2-compat.jar:/opt/cloudera/parcels/CDH/lib/hbase/hbase-client.jar:/opt/cloudera/parcels/CDH/lib/hbase/hbase-common.jar:/opt/cloudera/parcels/CDH/lib/hbase/lib/htrace-core.jar:/etc/hbase/conf

Seems like this is new for spark 1.x

kpeng
  • 81
  • 1
  • 9