J
jmr
Hi All,
I have an applet sending binary data to a server in order to save an image.
This works fine bug for very big images, I get an IOException "error
writing to server".
I don't know exactly the max size I could transfer (it worked ok for
3.5MB).Is there a limit somewhere ? I could not find it.
Note: this is NOT an OutOfMemory Exception.
The code is:
URL url = new URL(URLSave);
URLConnection uConn = url.openConnection();
uConn.setUseCaches(false);
uConn.setDoInput(true);
uConn.setDoOutput(true);
uConn.setRequestProperty("Content-transfer-encoding","binary");
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(uConn.getOutputStream());
// HERE SOME CODE TO FILL IN bos WITH IMAGE DATA
byte [] imageBytes = bos.toByteArray ();
String imageBase64 = Base64.encodeBytes (imageBytes);
String image = URLEncoder.encode (imageBase64);
System.out.println("Encoded Image size:" + image.length());
String parameters = "type=" + URLEncoder.encode(filetype) + "&data=" +
image;
out.write (parameters.getBytes());
out.flush();
out.close();
Thanks,
Jean-Michel
I have an applet sending binary data to a server in order to save an image.
This works fine bug for very big images, I get an IOException "error
writing to server".
I don't know exactly the max size I could transfer (it worked ok for
3.5MB).Is there a limit somewhere ? I could not find it.
Note: this is NOT an OutOfMemory Exception.
The code is:
URL url = new URL(URLSave);
URLConnection uConn = url.openConnection();
uConn.setUseCaches(false);
uConn.setDoInput(true);
uConn.setDoOutput(true);
uConn.setRequestProperty("Content-transfer-encoding","binary");
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(uConn.getOutputStream());
// HERE SOME CODE TO FILL IN bos WITH IMAGE DATA
byte [] imageBytes = bos.toByteArray ();
String imageBase64 = Base64.encodeBytes (imageBytes);
String image = URLEncoder.encode (imageBase64);
System.out.println("Encoded Image size:" + image.length());
String parameters = "type=" + URLEncoder.encode(filetype) + "&data=" +
image;
out.write (parameters.getBytes());
out.flush();
out.close();
Thanks,
Jean-Michel