# A FILE object defined in the contract is always madatory? Bonita 7.0.2

**URL:** <https://community.ofelia.com/t/a-file-object-defined-in-the-contract-is-always-madatory-bonita-7-0-2/6294>\
**Category:** Q&A\
**Created:** [12 August 2015 12:15 UTC](https://community.ofelia.com/t/a-file-object-defined-in-the-contract-is-always-madatory-bonita-7-0-2/6294 "2015-08-12T12:15:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vilcholo](https://avatars.discourse-cdn.com/v4/letter/v/b9bd4f/32.png) [@vilcholo](https://community.ofelia.com/u/vilcholo)\
**Post date:** [12 August 2015 12:15 UTC](https://community.ofelia.com/t/a-file-object-defined-in-the-contract-is-always-madatory-bonita-7-0-2/6294/1 "2015-08-12T12:15:55Z")

</div>

Hello,  
I am testing this process to upload and download [files](http://community.ofelia.com/project/file-upload-and-download-process-example). I have set the mandatory property of upload widget to false.  
When I throw the process, if I do not select a file in “Step Upload” and click “submit” the process does not continue to the next task and this message catalina log:

`2015-08-12 14:11:24.490 +0200 org.restlet.Component.BonitaRestletApplication org.bonitasoft.web.rest.server.api.resource.CommonResource manageContractViolationException INFORMACIÓN: Error while validating expected inputs Explanations: Expected input [myDocumentContract] is missing`

I need the file is optional. Could someone help me?  
Thank you. Best regards,

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/community_bonitasoft/original/2X/6/6b7b18c0478f2645369e82e009b65e3b97f2cc12.svg) [@system](https://community.ofelia.com/u/system)\
**Post date:** [12 August 2015 13:30 UTC](https://community.ofelia.com/t/a-file-object-defined-in-the-contract-is-always-madatory-bonita-7-0-2/6294/2 "2015-08-12T13:30:20Z")

</div>

Sadly it is not currently possible to have an optional file upload and I don’t have a workaround to propose.

File define in the contract input will actually accept null value but the operation “setDocument” will run anyway and will fail with a null value.

We currently looking at possible solutions to cover this important use case.

---

<div class="post-metadata">

**Author:** ![vilcholo](https://avatars.discourse-cdn.com/v4/letter/v/b9bd4f/32.png) [@vilcholo](https://community.ofelia.com/u/vilcholo)\
**Post date:** [13 August 2015 16:07 UTC](https://community.ofelia.com/t/a-file-object-defined-in-the-contract-is-always-madatory-bonita-7-0-2/6294/3 "2015-08-13T16:07:27Z")

</div>

Hello,  
I show my solution in case anyone is useful:  
I have introduced on the BDM a boolean variable “documentRequired”.

Task 1: In the form widget I have put a checkbox widget for the user to select is want to upload a document.  
I capture the value of the checkbox in the contract and modify the value of “documentRequired” with the value that the user have selected.

XOR gate: In the next step I have put an XOR gate that checks the value of “documentRequired” if “true” go to Task 2 (to upload the document) otherwise go to Task 3.

Task 2: The user uploads the document and go to Task 3.

Task 3: Continue the process …

---

<div class="post-metadata">

**Author:** ![chakrabandla](https://avatars.discourse-cdn.com/v4/letter/c/c68b51/32.png) [@chakrabandla](https://community.ofelia.com/u/chakrabandla)\
**Post date:** [24 August 2015 00:23 UTC](https://community.ofelia.com/t/a-file-object-defined-in-the-contract-is-always-madatory-bonita-7-0-2/6294/4 "2015-08-24T00:23:56Z")

</div>

Hi Antoine ,  
Can this issue be treated as a bug ? Is there any existing bug report for this?
