apache 限制每个资源的最大文件大小

kiayqfof  于 12个月前  发布在  Apache
关注(0)|答案(1)|浏览(131)

我使用Apache-cxf(JAX-RS)和spring框架。我在beans.xml中有以下示例代码。

<jaxrs:server id="services" address="${http.server}">
        <jaxrs:properties>
            <entry key="attachment-max-size" value="1024" />
        </jaxrs:properties>
        <jaxrs:serviceBeans>
            <bean id="mainResource" class="com.abc.rest.api.MainResource">
            <lookup-method name="createEmployeeCollectionResource"
                    bean="employeeCollectionResource" />
            </bean>
        ...
        ...other beans
        ...
        </jaxrs:serviceBeans>
    </jaxrs:server>

字符串
我也有以下代码

<bean id="employeeCollectionResource"
    class="com.abc.rest.services.EmployeeCollectionResourceImpl">
    <lookup-method name="createNewEmployeeResource" bean="employeeResource" />
</bean>
<bean id="employeeResource" scope="prototype"
    class="com.abc.rest.services.EmployeeResourceImpl">
</bean>


我已经设置了最大文件大小在上传为1 KB的所有服务一般。
我如何限制attachment-max-size用于特定的几个bean?示例-5 MB用于几个bean,2 MB用于几个其他bean,等等

cbjzeqam

cbjzeqam1#

您必须在单独的<jaxrs:server >标签中组织端点/资源,并对其附件大小进行自己的设置:

<jaxrs:server id="services">
    <jaxrs:properties>
        <entry key="attachment-max-size" value="1024" />
    </jaxrs:properties>
    ....
</jaxrs:server>

<jaxrs:server id="largeFileServices">
    <jaxrs:properties>
        <entry key="attachment-max-size" value="1000000" />
    </jaxrs:properties>
    ....
</jaxrs:server>

字符串
https://cxf.apache.org/docs/jax-rs-multiparts.html

相关问题