uploadFile service

hello ,
I want to save a file that uploaded from front end and save it in moqui and download the uploaded file when ever I want so can any body help me how can write a service in moqui to do this function ?

There already is functionality for this in Moqui. In a PopCommerce Wiki post, you can upload any file to have it stored in moqui. You can then access the information in the database. See: Webroot - Login

When you say front-end, I assume that you have a 3rd party application that you would like to add uploading functionality to. No service needs to be written if you use the default Wiki services and functionality. Refer to: SimpleScreens/wiki.xml at ab7e70b1dbb4b684c7a7a1443e5ecaa3488d14aa · moqui/SimpleScreens · GitHub a screen with the services used.

Assuming you want to do this for custom entities or something non-standard in moqui then there are two things that can help you. The ResourceFacade can help you with saving any file input that you receive from an upload form. The Web Facade on the other hand can help you with serving these contents.

There are plenty of examples in the framework if you study any upload form in any of the various screens and the focus is pretty much on downloading with ec.web.sendResourceResponse(...) and uploading can be done with InputStream, ec.resource.getLocationReference(...) and org.apache.commons.fileupload.FileItem as the input parameter to the service doing the uploading