Reputation: 513
we're using Alfresco 5.2 CE and are having a problem regarding file downloading.
We upload files through Share. Then, sometimes people rename the uploaded file to delete the file extension in the title.
But, when downloading those files to get a local copy, the document is downloaded without its extension.
The simple solution is to force people to not rename files after upload. The second one would be to modify the download links so that file extension is always added if missing. I've been searching where to change this but didn't find. Has somebody an idea of how to do this ?
Thanks in advance
Upvotes: 1
Views: 378
Reputation: 3818
I do not think that it is a good idea to introduce this customisation because the OOTB behaviour is correct and reasonable.
There are a lot of different ways to download the content of a document in Alfresco and you will need to make sure that you customise all of them to get a consistent name for the document.
If you are interested only in the name that you get when you download the document from Alfresco Share, you should customise the webscript that Share calls.
Using the development tool in your browser, you can see that Alfresco executes the following call:
This is using Share as a proxy for an "Alfresco" webscript (aka ACS).
The actual webscript called is:
/alfresco/service/slingshot/node/content/workspace/SpacesStore/86b142c2-7e51-4a49-9f5f-451e216e6d63/your-document-without-extension?a=true
The name passed to the wesbscript is completely ignored. The wesbcript decides the name of the downloaded file setting the response header "Content-Disposition" (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition)
If you want to find what is implementing that webscript, the easiest way is to use the "Alfresco service index" available at /alfresco/service/index/all
Search the path of the webscript "slingshot/node/content". You will find something like the snippet in the screenshot below (it can be different in a different version of Alfresco):
Click the link shown in the screenshot. This will open a page with information about that webscript.
There, you can see that the file descriptor for that webscript is "org/alfresco/slingshot/download.get.desc.xml". You should be able to find a bean in the Spring context with the id "webscripts.org.alfresco.slingshot.download.get" (I haven't checked, to be honest, but it should be there).
You can also see that the Java backed class is: org.alfresco.slingshot.web.scripts.SlingshotContentGet
You can start from there and see what you need to customise.
I know that this is not the complete answer, but I hope that it gives you a good example of steps to follow to find what you need in this case and in many others.
Upvotes: 2