01-21-2011 10:00 AM
01-21-2011 10:14 AM
File inputFile = new File(localTmpPath + "pippo.txt");
String remoteFileName = getUploadUrl();
URL url = new URL(remoteFileName);
URLConnection ucon = url.openConnection();
BufferedInputStream in = new BufferedInputStream(new FileInputStream(inputFile));
ucon.setDoOutput(true);
BufferedOutputStream out = new BufferedOutputStream(ucon.getOutputStream());
int i = 0;
byte[] bytesIn = new byte[1024];
while ((i = in.read(bytesIn)) >= 0) {
out.write(bytesIn, 0, i);
}
out.flush();
out.close();
in.close();
public String getUploadUrl(){
int port;
if(getDocumentBase().getPort()!=-1){
port = getDocumentBase().getPort();
} else {
port = 8080;
}
Socket socket = null;
try {
socket = new Socket(getDocumentBase().getHost(), port);
} catch (Exception ex) {
ex.printStackTrace();
}
String ip = socket.getLocalAddress().getHostAddress();
// Get a reference to the
AuthenticationServiceSoapBindingStub authenticationService = null;
try {
authenticationService = (AuthenticationServiceSoapBindingStub) new AuthenticationServiceLocator()
.getAuthenticationService(new URL("http://'+ip +":"+port+"/alfresco"+"/api/"+"AuthenticationService"));
} catch (Exception ex) {
ex.printStackTrace();
}
// Start the session
AuthenticationResult result = null;
try {
result = authenticationService.startSession("admin", "admin");
} catch (Exception ex) {
ex.printStackTrace();
}
ticket = result.getTicket();
String res = "http://'+ip +":"+port+"/alfresco/upload/"+ nodeRef.replace(":", "").replace("//", "/")+"/"+fileName"?ticket="+ticket; //***
jTextField3.setText(res);
return res;
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.