Reputation: 269
my EbooksEntities.xml file
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/entity-definition-2.1.xsd">
<entity entity-name="Ebook" package="moqui.ebook" short-alias="ebooks">
<field name="ebookId" type="id" is-pk="true"><description>primary sequenced ID</description></field>
<field name="md5" type="text-medium"/>
<field name="file" type="binary-very-long" />
</entity>
</entities>
my ebook.rest.xml file
<resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/rest-api-2.1.xsd" name="ebook" displayName="Ebook REST API" version="2.0.0">
<resource name="ebooks">
<method type="get"><entity name="ebooks" operation="list"/></method>
<method type="post"><entity name="ebooks" operation="create"/></method>
</resource>
</resource>
now swagger REST API browser shows file parameter as String. How can I create REST method to post binary file?
Upvotes: 0
Views: 72
Reputation: 1842
You’ll need to write your own service that utilizes the ResourceFacade to copy the file to the DB or file system and then update the entity with the resource location.
You cannot use an entity-auto service, such as the ones listed in your answer, for this type of operation.
Upvotes: 0