As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
Example URL with NodeRef not provided: /alfresco/upload/myfile.pdf
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_file.pdf/your_file.pdf?ticket='+ticket; //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()); }