11-17-2011 02:11 AM
Example URL with NodeRef not provided:
/alfresco/upload/myfile.pdf
11-23-2011 05:10 AM
HttpClient httpClient = new HttpClient();
PostMethod method = new PostMethod(base);
String input = "{" +
"\"name\" : \"" + params.getParameter("name") +"\", " +
"\"type\" : \"" + params.getParameter("type") + "\", " +
"\"content\" : \"" + params.getParameter("content") //only string for JSON parser -> temp content, overwritten in step 2
+ "\" }";
method.setRequestEntity(new StringRequestEntity(input,"application/json", null));
int statusCode = httpClient.executeMethod(method);
String base = "http://192.168.0.141:8080/alfresco/upload/avm/pim--admin/-1;www;avm_webapps;ROOT;YOUR_FOLDER;your_fi...;
//get file stream
File file = new File("d:\\your_file.pdf");
long length = file.length();
if (length > Integer.MAX_VALUE) {
System.err.println("file to large !!!");
}
byte[] contentBytes = new byte[(int)length];
FileInputStream fis = new FileInputStream(file);
HttpClient httpClient = new HttpClient();
// Credentials cred = new UsernamePasswordCredentials("admin","tim");
// httpClient.getState().setCredentials(AuthScope.ANY, cred);
PutMethod method = new PutMethod(base);
method.setRequestEntity(new InputStreamRequestEntity(fis));
// method.addRequestHeader("Expect","100-continue");
method.setParams(params);
int statusCode = httpClient.executeMethod(method);
if (statusCode != HttpStatus.SC_OK) {
System.err.println("Method failed: " + method.getStatusLine());
}
08-12-2014 10:15 AM
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.