AnsweredAssumed Answered

File upload in create-content of custom content types

Question asked by itzamna on Sep 24, 2013
Hi all,

we're providing an interface to connect Alfresco with another system. Therefore we've a custom content model, but documents of our types are usually created by batch jobs or import jobs not by end-users. For presentation purposes (mainly) and to provide the opportunity to create documents of our custom content types manually in rare cases at all, I was able to customize the share-custom-config.xml in a way that all our properties and aspects for the documents appears. Blank documents are created, so it works in general. But now I need the opportunity to upload a file in the create mask as content for the document. I found already some approaches but none of them matches the requirement:
For example, the content type selection when uploading a file would already fit the needs (even it's not supported yet: but this does not work on Linux installations, because the dnd-upload will close the popup immediately after uploading the files (without letting the user choose the content type). We can not override this function, as we do not have influence to the customer (and their systems) who will install our provided AMP file.
Also I found the approach with the "submission-url" property in the <form> tag: But this seems to be a lot of programming effort, which is not my intention as it should be only a means to end. In general, I think this approach sounds promising but the post is older than 3 years. Maybe with Alfresco 4.2 the requirement can be solved with customizing only? Or at least with a minimum of programming and without to override Alfresco resources?

What is currently the easiest way to provide the creation of documents in Alfresco Share for custom content types with a file upload?

My idea is to extend the share-config-custom.xml like:

<config evaluator="string-compare" condition="DocumentLibrary">
      <content id="myType" mimetype="text/plain" icon="myTypeIcon" label="myType.createcontent" itemid="myPrefix:myType"/>

The create form of custom content type (custom types are derived from cm:content):

<config evaluator="model-type" condition="myPrefix:myType">
            <form submission-url="/myApplication/upload">
                    <show id="myPrefix:Property1"/>
                    <show id="myPrefix:Property2"/>
                    <show id="myPrefix:Property3" />
                    <show id="cm:name"/>
                    <show id="cm:content" force="true" />
                    <set id="basic" appearance="bordered-panel" label-id="basic.create.label" />
                    <set id="my" appearance="bordered-panel" label-id="myType.create.label" />
                    <field id="myPrefix:Property1" set="my"/>
                    <field id="myPrefix:Property2" set="my"/>
                    <field id="myPrefix:Property3" set="my"/>
                    <field id="cm:name" set="basic"/>
                    <field id="cm:content" set="basic" >
                        <control template="/org/alfresco/components/form/controls/fileUpload.ftl" />

Where fileUpload.ftl is (from post above):

<div class="form-field">
    <label for="${fieldHtmlId}">${field.label?html}:<#if field.mandatory><span class="mandatory-indicator">${msg("form.required.fields.marker")}</span></#if></label>
    <input type="file" id="${fieldHtmlId}" name="${}" />

But I dont know to handle the submission-url. Do I have to save all properties in the form in the webscript behind? At least I only need to hande the file upload as the rest will be done by Alfresco already.