C
crazytazo
PostMethod filePost = new PostMethod(ui.value.getStrEIP());
filePost.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE,
true);
try {
Part[] parts = {
new StringPart("FILENAME", file.m_File.getName()),
new StringPart("DIRFLAG", String.valueOf(0)),
new StringPart("FILEINDEX", String.valueOf(jfidx)),
new StringPart("FILESAVEPATH", ui.value.getStrPath()),
new FilePart(file.m_File.getName(), file.m_File)
};
filePost.setRequestEntity(
new MultipartRequestEntity(parts,
filePost.getParams()));
HttpClient client = new HttpClient();
client.getHostConfiguration().setHost(ui.value.getStrEIP(), 80);
client.getHttpConnectionManager().
getParams().setConnectionTimeout(5000);
int status = client.executeMethod(filePost);
if (status == HttpStatus.SC_OK) {
System.out.println("Upload complete, response=" +
filePost.getResponseBodyAsString());
} else {
System.out.println("Upload failed, response=" +
HttpStatus.getStatusText(status));
}
} catch (Exception ex) {
System.out.println("ERROR: " + ex.getClass().getName() + "
" + ex.getMessage());
ex.printStackTrace();
} finally {
filePost.releaseConnection();
}
this is client code using apache.HTTPClient.
it's work well, but follow line is occur blocking until get response
code from server.
int status = client.executeMethod(filePost);
How to check writing bytes in this modules?
The bytes are need to represnt progressbar.
filePost.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE,
true);
try {
Part[] parts = {
new StringPart("FILENAME", file.m_File.getName()),
new StringPart("DIRFLAG", String.valueOf(0)),
new StringPart("FILEINDEX", String.valueOf(jfidx)),
new StringPart("FILESAVEPATH", ui.value.getStrPath()),
new FilePart(file.m_File.getName(), file.m_File)
};
filePost.setRequestEntity(
new MultipartRequestEntity(parts,
filePost.getParams()));
HttpClient client = new HttpClient();
client.getHostConfiguration().setHost(ui.value.getStrEIP(), 80);
client.getHttpConnectionManager().
getParams().setConnectionTimeout(5000);
int status = client.executeMethod(filePost);
if (status == HttpStatus.SC_OK) {
System.out.println("Upload complete, response=" +
filePost.getResponseBodyAsString());
} else {
System.out.println("Upload failed, response=" +
HttpStatus.getStatusText(status));
}
} catch (Exception ex) {
System.out.println("ERROR: " + ex.getClass().getName() + "
" + ex.getMessage());
ex.printStackTrace();
} finally {
filePost.releaseConnection();
}
this is client code using apache.HTTPClient.
it's work well, but follow line is occur blocking until get response
code from server.
int status = client.executeMethod(filePost);
How to check writing bytes in this modules?
The bytes are need to represnt progressbar.