cancel
Showing results for 
Search instead for 
Did you mean: 

Force upload extension

ahmed_chaabane
Champ on-the-rise
Champ on-the-rise

Hello community !

I am trying to force an extension while uploading my file on a local document type. I want to know if it is possible. And if yes, where I can write the mime-type wanted ?

Thank you

1 ACCEPTED ANSWER

Gregory_Carlin
Elite Collaborator
Elite Collaborator

If you need to block the upload if the mime-type is not the good one, then I think you should have controls on the UI side, i.e. on your import layout, in the Polymer section.

View answer in original post

6 REPLIES 6

Gregory_Carlin
Elite Collaborator
Elite Collaborator

Hello Ahmed,

Have you tried to run a Document.SetProperty on "file:content": { "mime-type": "XXX" } field and update the mimetype with your value? (For example on the documentCreated event with a filter on your custom doctype?)

You can also run a new converter through the following extension point: http://explorer.nuxeo.com/nuxeo/site/distribution/Nuxeo%20Platform%20LTS%202019-10.10/viewExtensionP...

ahmed_chaabane
Champ on-the-rise
Champ on-the-rise

Hello Mr Gregory,

Thank you for your answer. I have tried the first proposition by creating an event handler where the current document has my local custom document type. And the event handler execute an automation chain that uses Document.SetProperty (as seen in the screenshot) An error is occuring while uploading my document type exactly in the value: {“mime-type”: “XXX” }:

org.nuxeo.ecm.automation.OperationException: Only scalar types can be set using update operation

Automation

Please tell me if the process is correct.

Thank you very

Gregory_Carlin
Elite Collaborator
Elite Collaborator

It should be XPath : file:content/mime-type and with value image/vnd.dwg

ahmed_chaabane
Champ on-the-rise
Champ on-the-rise

Thank you very much Mr Gregory, the mime-type is set exactly as I want. It would be better for me to block upload event when mime-type is different from the ones wanted. I think that running a script would help me. I don't know only the action that blocks the creation event if conditions are not satisfied.

Thank you

Gregory_Carlin
Elite Collaborator
Elite Collaborator

If you need to block the upload if the mime-type is not the good one, then I think you should have controls on the UI side, i.e. on your import layout, in the Polymer section.

ahmed_chaabane
Champ on-the-rise
Champ on-the-rise

Thank you very much Mr Gregory,

I have resolved the problem by adding the parameter accept with the wanted extensions to the nuxeo-dropzone tag in create-layout:

<nuxeo-dropzone role="widget"
                label="[[i18n('file.content')]]"
                name="content"
                document="{{document}}"
                accept=".dwg,.dxf,.dgn"
                message="Upload a CAD document"></nuxeo-dropzone>