Hello Everyone,
While downloading the file from Appliaction UI we are getting file name as "eb3e60e5-ae30-4a7b-8321-8cd2dcf2b7b9" instead of original file name as in alfresco like AS_ID.
this is my sample code written in java:
void dowload(DownloadRequest dr, HttpServletResponse hResponse){
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
HttpGet httpGet = new HttpGet(dr.getUrlToDownload());
HttpResponse response = httpClient.execute(httpGet);
HttpEntity entity = response.getEntity();
if (entity != null) {
// code to read file content
}
hResponse.setHeader("Content-Disposition", "attachment; filename=\"" + dr.getFileName() + "\"");
}
can anyone help me out how to download file with exact filename.
It not quite clear what url you are using and what params are being sent for download request, are creating any custom download webscript or trying to use OOTB download api?
For refrence to use OOTB download api you can look at this class:
If correct url is used and all required params are passed, you should get the file with correct name always. Check the above class for example.
GET /alfresco/service/api/node/content/{store_type}/{store_id}/{id}?a=false&alf_ticket={TICKET}
Example:
http://127.0.0.1:8080/alfresco/service/api/node/content/workspace/SpacesStore/85d2a84d-271b-41b1-944...
Where:
a: means attach. if true, force download of content as attachment. Possible values are true/false
store_type: workspace
store_id: SpacesStore
id: nodeRefId (UUID of the node)
This post shows example of custom download webscript:
https://javaworld-abhinav.blogspot.com/2017/08/downloading-content-from-alfresco.html
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.