Download File Naming issue using 6.0.2v of alfresco

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2020 12:14 PM
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.
- Labels:
-
Alfresco Content Services
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2020 01:11 PM
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)
Store Protocol - that is, the type of store
Store Identifier - the id of the store
Example storeRefs are:
workspace://SpacesStore (store_type://store_id)
version://versionStore (store_type://store_id)
archive://SpacesStore (store_type://store_id)
This post shows example of custom download webscript:
https://javaworld-abhinav.blogspot.com/2017/08/downloading-content-from-alfresco.html
(ACSCE, AWS SAA, Azure Admin)
