【问题标题】:Restricting max file size per resource限制每个资源的最大文件大小
【发布时间】:2014-11-20 11:19:10
【问题描述】:

我正在使用 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>

我已将所有服务上传期间的最大文件大小设置为 1KB。

我怎样才能特别限制 attachment-max-size 对于少数 bean?示例 - 少数 bean 5MB,其他少数 2MB 等

【问题讨论】:

    标签: java spring apache cxf jax-rs


    【解决方案1】:

    您将不得不在单独的&lt;jaxrs:server &gt; 标签中组织您的端点/资源,并使用它们自己的附件大小设置:

    <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>
    

    http://cxf.apache.org/docs/jax-rs-multiparts.html

    【讨论】:

      猜你喜欢
      • 2017-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多