Force upload extension

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

0 votes

6 answers

79 views

ANSWER



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.

0 votes



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

1 votes



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/viewExtensionPoint/org.nuxeo.ecm.core.convert.service.ConversionServiceImpl–converter

1 votes



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>
0 votes



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

0 votes



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

FILES:   cadChain.png
0 votes