06-01-2018 01:26 PM
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,
06-02-2018 04:26 AM
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.
06-04-2024 04:56 AM
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
Explore our Alfresco products with the links below. Use labels to filter content by product module.