How to set default mimetype for custom models

cancel
Showing results for 
Search instead for 
Did you mean: 
udayakumar_p
Active Member

How to set default mimetype for custom models

Jump to solution

Say we have a custom model named common:faq. It has properties cm:name, common:question, common:answer. How do i tell alfresco to set the default mimeype as text/plain for the contents created from this model?

When we create a content from this model, we see that the mimetype is set as 'application/octet-stream. instead we want this to be set to text/plain. How to configure this?

Note: when we create a content from other content models which has a cm:content property, alfresco sets the mimetype as text/plain by default.

Alfresco content service version: 5.2

1 Solution

Accepted Solutions
douglascrp
Advanced II

Re: How to set default mimetype for custom models

Jump to solution

I don't think you will be able to set the mimetype using the available Share actions.

At least I tried to find the right way to do it by using the form configuration, and I could not find it.

So, you should try another way, that is using the action Execute Script, and then having a javascript with a code just like the following:

document.mimetype = "text/plain";
document.save();

I tried it this way myself and it worked.

View solution in original post

16 Replies
afaust
Master

Re: How to set default mimetype for custom models

Jump to solution

This is something you'd have to do via a policy / behaviour (i.e. onCreateNode) if you cannot already provide the correct mimetype as part of the content upload or implied via the file name (Alfresco will use the file extension to "guess" mimetypes, i.e. if your node is named xy.txt it will set text/plain automatically).

udayakumar_p
Active Member

Re: How to set default mimetype for custom models

Jump to solution

Hi,

Thanks, Can you please give more detail on how to do it via a policy / behaviour (i.e. onCreateNode). This is an ongoing issue in our app which needs immediate fix.

udayakumar_p
Active Member

Re: How to set default mimetype for custom models

Jump to solution

Can we able to do it by mentioning as below,

<show id="mimetype" />.

We don't want to show the field to the user and we want to set the value to text/plain always. How to set that?

udayakumar_p
Active Member

Re: How to set default mimetype for custom models

Jump to solution

I have created a rule to be run for updating the mimetype but it does not work.

afaust
Master

Re: How to set default mimetype for custom models

Jump to solution

Is the node already of the required type during creation / moving into the folder? Otherwise you may want to also add the "When" for items updated. You can also add a mimetype check as a criteria, so it does not get triggered when the mimetype is already complete.

udayakumar_p
Active Member

Re: How to set default mimetype for custom models

Jump to solution

Hi,

We are creating the content from create menu item. This means, we have a list of custom models in a dropdown from which we can create content. I added "when" for items updated, but still mimetype not set to text/plain.

udayakumar_p
Active Member

Re: How to set default mimetype for custom models

Jump to solution

The rule does not run at all. I just changed the condition like if name equals something set the mimetype.

I removed the condition totally and tried. Even this rule does not trigger.

So i think setting the cmis:contentStreamMimeType value does not work.

douglascrp
Advanced II

Re: How to set default mimetype for custom models

Jump to solution

I don't think you will be able to set the mimetype using the available Share actions.

At least I tried to find the right way to do it by using the form configuration, and I could not find it.

So, you should try another way, that is using the action Execute Script, and then having a javascript with a code just like the following:

document.mimetype = "text/plain";
document.save();

I tried it this way myself and it worked.

udayakumar_p
Active Member

Re: How to set default mimetype for custom models

Jump to solution

Seem to be working. Let me try more scenarios.

Thanks for the help.