0

My server is sending me chunked encoded data and I am able to get the chunked response in my client. The problem I am facing is that some chunks are too big, ca 10 MB. I am getting an exception as I have set max chunk size to 2M.

Is there any way to break this bigger chunk into smaller ones?

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
Tinku
  • 1,592
  • 1
  • 15
  • 27

2 Answers2

1

Hmm. Not sure what version of Spray you're using but starting from version 1.1 there is incoming-auto-chunking-threshold-size setting (details here). Here is example of service that supports chunked upload.

There are still number of limitations at the moment. You could read relevant discussion in open ticket.

expert
  • 29,290
  • 30
  • 110
  • 214
0

you can devide big chunk in smaller chunks by using RandomAccessFile. I had same problem. I resolved it using RandomAccessFile.

you can do it following way.

byte[] bytes;
String filePath = "path";
RandomAccessFile file1 = new RandomAccessFile(filePath, "r");

      file1.seek(0);
      bytes = new byte[(int)file1.length()/3];
      file1.read(bytes);
      file1.close();
      String str = new String(bytes, "UTF-8");
Divyang Shah
  • 1,578
  • 1
  • 11
  • 22