1

For my current solution, I'm using apache commons FileUpload library to process incoming multi-part requests. I'm able to send the files appropriately then read the stream on the server end using the streaming api code here.

If you look at the format of multipart requests listed here, there is a Content-Disposition listed for each file added. I need to add a startByte tag (similar to how you add a "filename" tag in content-disposition). I'm not too sure how to do that properly and then retrieve it in the request? This is of course not a global header, because multiple files are in this stream.

Anyone have any ideas?

Community
  • 1
  • 1
Deftness
  • 265
  • 1
  • 4
  • 21

1 Answers1

1

This is for anyone who might be interested, and turns out was easy: To do this, on the client, you append the header like below:

 outputStream.writeBytes("Content-Disposition: form-data; name=\"" + filename + "\"; filename=\"" + filename + "\";\r\n");
 outputStream.writeBytes("My-Custom-Header: My-Data\r\n");
 outputStream.writeBytes("\r\n");

Then, on the server, using commons FileUpload, you would just do:

FileItemHeaders headers = item.getHeaders();
headers.getHeader("My-Custom-Header");
Deftness
  • 265
  • 1
  • 4
  • 21