Download File Naming issue using 6.0.2v of alfresco

cancel
Showing results for 
Search instead for 
Did you mean: 
Aswani_Juvva
Active Member II

Download File Naming issue using 6.0.2v of alfresco

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. 

 

1 Reply
abhinavmishra14
Advanced

Re: Download File Naming issue using 6.0.2v of alfresco

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:

https://github.com/abhinavmishra14/alfresco-scripts/blob/master/src/main/java/com/github/abhinavmish...

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.

REST API for download file/node is: (It should be HTTP Get request)
 

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)

 
A StoreRef is comprised of:

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

 

~Abhinav
(ACSCE, AWS SAA, Azure Admin)