File upload

Description: extension for uploading files with use FileRepository implementation

Maven module:

OpenHub's extensions are under construction, it's coming soon ...


        <groupId>org.openhubframework.openhub.extensions</groupId>
        <artifactId>file-upload</artifactId>

Packageorg.openhubframework.openhub.extension.fileupload

 

RouteUploadFileRoute
IN/OUTIN
URL

.../http/upload

Description

File is uploaded via PUT HTTP method.

Input file is uploaded to temporary directory with unique file identifier (fileId) that is returned back.
When this fileId comes with other data then the file is moved and renamed to right target folder.


Uploading files can be tested with curl command tool:

curl -i -X PUT -T "/Volumes/Obelix/context.xml" http://localhost:8080/esb/http/...
Configuration 
ParameterDefault valueDescription
file.maxUploadedFileSize5000Maximum size (in kB) for uploaded files
file.upload.servletNameCamelServletServlet name defined in web.xml for uploading files

web.xml:

    <!-- Camel servlet-->
    <servlet>
        <servlet-name>CamelServlet</servlet-name>
        <servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>CamelServlet</servlet-name>
        <url-pattern>/http/*</url-pattern>
    </servlet-mapping>
Error codes

See ErrorFileUploadEnum

Error codeDescription
E100it's possible to use HTTP PUT method only
E101uploaded file exceeded maximum possible size
Prerequisites

File upload uses FileRepository contract and therefore it's necessary to inicialize FileRepository's implementations.

<bean id="fileRepository" class="org.openhubframework.openhub.core.common.file.DefaultFileRepository"/>

DefaultFileRepository uses ohf.dir.temp and ohf.dir.fileRepository configuration properties, see Configuration page for more details.

Notes