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;
}
Archive content from product discussions in Italian.
This group is now closed and content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.