cancel
Showing results for 
Search instead for 
Did you mean: 

Setting mime types using JCR

dnatarajan
Champ in-the-making
Champ in-the-making
Hi everyone -

I’ve managed to create a few of custom content types in the alfresco repository – and am able to add a custom content node using JCR (over RMI – we didn’t find sufficient documentation how to configure the application to use local JCR). Is it possible to set the mime type for a content node with a JCR call? This is supported in the specification, but I couldn’t find an example in the enterprise SDK (e.g adding jcr:mimeType to a nt:resource type node)

If anyone can help us or point us to some good documentation, that would be fantastic!

Thanks in advance!
1 REPLY 1

arun5s
Champ in-the-making
Champ in-the-making
NodeService nodeService = registry.getNodeService();
        ContentData content = (ContentData)nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT);
        String mim=registry.getMimetypeService().guessMimetype(fileName).toString();
      


        content = ContentData.setMimetype(content, mim);
        nodeService.setProperty(nodeRef, ContentModel.PROP_CONTENT, content);      
        registry.getFileFolderService().getReader(nodeRef).setMimetype(mim);


The above code will be used to set mimetype for file Smiley Very Happy