1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
http2 = (HttpConnection) Connector.open(monUrl);
http2.setRequestProperty("CONTENT-TYPE", "application/x-www-form-urlencoded");
http2.setRequestMethod(HttpConnection.POST);
byte[] img = (byte[])fotosByte.elementAt(x);
byte data[] ;//
String stringImage = base64.encode(img);
System.out.println(stringImage.length());
int index = 0;
int size = 1024;
int total = stringImage.length();
double percent = 0;
outStrm = http2.openDataOutputStream();
do{
data = ("foto=").getBytes();
outStrm.write(data);
if ( (index + size) > stringImage.length() ) {
size = stringImage.length() - index;
outStrm.write((stringImage.substring(index, size + index)).getBytes());
percent = (double) (100 * ((float) index / (float) total));
System.out.println("finish");
} else {
outStrm.write((stringImage.substring(index, size + index)).getBytes());
percent = (double) (100 * ((float) index / (float) total));
System.out.println(percent);
}
outStrm.flush();
index += size;
} while( index < stringImage.length() ); |
Partager