hi,
I am wondering if there is anyway we can set/assign the content-mime type of a document being created using REST API.
I use the below this rest api and I need to be able to set mimetype directly when the document is being created.
Is that possible?
I did a few try and errors it seems that mimetype is determined based on the extension given to the name property passed to the api.
So if I for example use the below as the json post parameter, the mimetype becomes application/pdf but
{
"name": "filename.pdf",
"nodeType": "string",
}
if use the below, the mimetype becomes applicaiton/image.
{
"name": "filename.png",
"nodeType": "string",
}
Please advise if that can be set using REST API.
Thank you,
You cannot set mime type when uploading, as it's autodetected.
If you find any case where this detection process fails, you can modify mime type after uploading the content.
Can you give a example for this ?
I have tried this:
FormData data = new FormData();
data.addFieldData("prop_mimetype", mimetype, true); Item itemMimetype = new Item("node", nodeRef.toString()); NodeRef nodeRefFoundedUpdated = (NodeRef)formService.saveForm(itemMimetype, data);
and this:
ContentWriter contentWriter = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
if(contentWriter != null) {
contentWriter.setMimetype(mimetype);
}
but is not working is still a "application/octet-stream" value on alfresco share
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.