Hi All,
I am facing issue in downloading document with correct mimetype.
Issue is when i create a file by uploading content of type .pdf with the API like this:-
File is created without extension though it should take extension as .pdf as its contents but it is created without extension like below:-
If i check from node browser it mimetype is application/pdf:-
And when i tried to download it is shows of type of File is:- FILE instead of .pdf like below:-
So my query is how to get document downloaded correctly as its content is uploaded in .pdf format. So download should be as similar as .pdf.
Thanks and Regards,
Piyush
Hi @piyush48
Have you tried setting the mimetype when uploading?
"content": { "mimeType": "string", "mimeTypeName": "string" },
https://api-explorer.alfresco.com/api-explorer/#!/nodes/updateNode
HTH
The result seems to be expected as you are not passing the extension in the name. "name" input param maps to cm:name property. When you pass the name param, it will simply apply the input name as is to cm:name property.
This is default unless you implement a custom behavior which listens to node creation event and guess the mimetype + extension and append the extension in the name via custom code.
To verify the name property mapping, use the below url to get all the properties for the recently uploaded file based on its id (nodeRefId) returned in the upload response:
e.g., id:7cea002a-07f8-47d8-8db8-721fc0858ce3
http://127.0.0.1:8080/alfresco/service/api/metadata?nodeRef=workspace://SpacesStore/7cea002a-07f8-47d8-8db8-721fc0858ce3
You will see the properties like:
....
properties: { ..... {http://www.alfresco.org/model/system/1.0}node-uuid: "7cea002a-07f8-47d8-8db8-721fc0858ce3", {http://www.alfresco.org/model/content/1.0}name: "CMIS Tutorial", .... .... }
....
So in short, solution to your problem is that-> don't pass name parameter and system will automatically recognize the name of the file at the time of upload and map it to cm:name property. The cm:name will be same as the file name you are uploading. And since extension will be already present, download issue will go away.
See examples here:
https://docs.alfresco.com/6.1/concepts/dev-api-by-language-alf-rest-upload-file.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.