0

我正在尝试将文件上传到共享文件夹...这是我的代码。

// using httpclient-4.5

Path filePath = Paths.get("C:/afile.txt");
String ticket = getTicket();  //  get a ticket via /alfresco/service/api/login...

CloseableHttpClient client = HttpClients.createDefault();
HttpPost post = new HttpPost("http://localhost:8080/alfresco/service/api/upload?alf_ticket=" + ticket);
MultipartEntityBuilder entity = MultipartEntityBuilder.create();

StringBody descriptionBody = new StringBody("a test", ContentType.TEXT_PLAIN);
StringBody siteId = new StringBody("company_home", ContentType.TEXT_PLAIN);    //  how can upload the file 
StringBody containerid = new StringBody("/Shared", ContentType.TEXT_PLAIN);    //  in the shared folder??

entity.addBinaryBody("filedata", filePath.toFile());
entity.addPart("siteid", siteId);
entity.addPart("containerid", containerid);

post.setEntity(entity.build());

CloseableHttpResponse postResponse = client.execute(post);

// ...

谁能帮我?谢谢。

4

0 回答 0