cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to Download document of Correct Mimetype

piyush48
Star Contributor
Star Contributor

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:-imageCreating a Document with API

File is created without extension though it should take extension as .pdf  as its contents but it is created without extension like below:-

image

If i check from node browser it mimetype is application/pdf:-

image

And when i tried to download it is shows of type of File is:- FILE instead of .pdf like below:-

image

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

2 REPLIES 2

EddieMay
World-Class Innovator
World-Class Innovator

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

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!

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

~Abhinav
(ACSCE, AWS SAA, Azure Admin)