01-30-2010 09:18 AM
File Upload
POST /alfresco/service/api/upload
—
Upload file content and meta-data into repository.
HTML form data
* filedata, (mandatory) HTML type file
* siteid
* containerid
* uploaddirectory
* updatenoderef
* filename
* description
* contenttype
* majorversion
* overwrite
* thumbnails
<html>
<body>
<form method="post" action="http://localhost:8080/alfresco/service/api/upload?alf_ticket=TICKET_405f319152813bc46da98266b83777cf..." >
<input type="file" name="filedata" />
<input type="hidden" name="description" value="a description" />
<input type="hidden" name="filename" value="myFile" />
<input type="hidden" name="containerid" value="af05cb2c-8100-442c-8dce-de81a8de57b0"/>
<input type="submit" name="submit" value="upload" />
</form>
</body>
</html>
// Instancite object
DefaultHttpClient httpClient = new DefaultHttpClient();
// Set Authentication
if(USE_CREDENTIALS) {
Credentials credentials = new UsernamePasswordCredentials(LOGIN, PWD);
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, credentials);
httpClient.setCredentialsProvider(credentialsProvider);
}
else if(USE_TICKET) {
URL = URL + "?alf_ticket=" + TICKET;
}
// Use Post
HttpPost request = new HttpPost(URL);
// Read Server Response
HttpResponse response = httpClient.execute(request);
// Checking response…
if( response.getStatusLine().getStatusCode() == 200 ) {
String json = getJSon(response.getEntity().getContent());
System.out.println("JSON received: " + json);
}
else {
System.err.println("Upload Failed: \n"
+ response.getStatusLine().getStatusCode() + " : " + response.getStatusLine().getReasonPhrase() + "\n"
+ getJSon(response.getEntity().getContent()) );
}
01-30-2010 10:00 AM
01-30-2010 11:22 AM
Look on the server and see if there is an error in the alfresco.log file. That may give you a clue as to what you are doing wrong.Thx for the fast reply, but is not errors in the log file or console.
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.