修改下载链接地址格式为正确的URL格式(例如:http://localhost:8080/alfresco/download/direct?path=/Company%20Home/File%20Name.txt)并使用有效的凭证进行身份验证。
示例代码:
String downloadURL = "http://localhost:8080/share/proxy/alfresco/api/node/content/workspace/SpacesStore/docId/file.pdf?alf_ticket=TICKET_acbdefghijkl"; String correctURL = downloadURL.replace("/share/proxy/alfresco/", "/alfresco/download/direct?path="); correctURL = correctURL.substring(0, correctURL.indexOf("?")); HttpClient client = HttpClients.createDefault(); HttpGet request = new HttpGet(correctURL); request.addHeader("Authorization", "Basic " + Base64.encodeToString("Username:Password".getBytes())); HttpResponse response = client.execute(request); InputStream is = response.getEntity().getContent();