use of javax.servlet.MultipartConfigElement in project meecrowave by apache.
the class ProxyServletSetup method accept.
@Override
public void accept(final Context context) {
final Configuration config = instance.getConfiguration().getExtension(Configuration.class);
if (config.skip) {
return;
}
context.addServletContainerInitializer((c, ctx) -> {
final ServletRegistration.Dynamic servlet = ctx.addServlet("meecrowave-proxy-servlet", CDIProxyServlet.class);
servlet.setLoadOnStartup(1);
servlet.setAsyncSupported(true);
servlet.addMapping(config.mapping);
if (config.multipart) {
servlet.setMultipartConfig(new MultipartConfigElement(config.multipartLocation, config.multipartMaxFileSize, config.multipartMaxRequestSize, config.multipartFileSizeThreshold));
}
servlet.setInitParameter("mapping", config.mapping);
servlet.setInitParameter("configuration", config.configuration);
}, null);
}
use of javax.servlet.MultipartConfigElement in project qpid-broker-j by apache.
the class HttpManagement method addRestServlet.
private void addRestServlet(final ServletContextHandler root) {
final Map<String, ManagementControllerFactory> factories = ManagementControllerFactory.loadFactories();
final long maxFileSize = getContextValue(Long.class, MAX_HTTP_FILE_UPLOAD_SIZE_CONTEXT_NAME);
final int maxRequestSize = getContextValue(Integer.class, MAX_HTTP_FILE_UPLOAD_SIZE_CONTEXT_NAME);
final List<String> supportedVersions = new ArrayList<>();
supportedVersions.add("latest");
String currentVersion = BrokerModel.MODEL_VERSION;
ManagementController managementController = null;
ManagementControllerFactory factory;
do {
factory = factories.get(currentVersion);
if (factory != null) {
managementController = factory.createManagementController(this, managementController);
final RestServlet managementServlet = new RestServlet();
final Collection<String> categories = managementController.getCategories();
for (String category : categories) {
final String name = category.toLowerCase();
final String path = managementController.getCategoryMapping(name);
final ServletHolder servletHolder = new ServletHolder(path, managementServlet);
servletHolder.setInitParameter("qpid.controller.version", managementController.getVersion());
servletHolder.getRegistration().setMultipartConfig(new MultipartConfigElement("", maxFileSize, -1L, maxRequestSize));
root.addServlet(servletHolder, path + (path.endsWith("/") ? "*" : "/*"));
if (BrokerModel.MODEL_VERSION.equals(managementController.getVersion())) {
root.addServlet(servletHolder, "/api/latest/" + name + "/*");
}
}
supportedVersions.add("v" + currentVersion);
currentVersion = factory.getPreviousVersion();
}
} while (factory != null);
root.getServletContext().setAttribute("qpid.controller.chain", managementController);
final Map<String, List<String>> supported = Collections.singletonMap("supportedVersions", supportedVersions);
final ServletHolder versionsServletHolder = new ServletHolder(new JsonValueServlet(supported));
root.addServlet(versionsServletHolder, "/api");
root.addServlet(versionsServletHolder, "/api/");
}
use of javax.servlet.MultipartConfigElement in project BroadleafCommerce by BroadleafCommerce.
the class AdminMultipartUploadConfig method multipartConfigElement.
@Bean
public MultipartConfigElement multipartConfigElement(Environment env) {
MultipartConfigElement multipartConfig = this.multipartProperties.createMultipartConfig();
// If a user has configured the max file size from Broadleaf to be anything,
// override it here
String blcAssetUploadSizeProperty = "asset.server.max.uploadable.file.size";
Long blcMaxFileSize = env.getProperty(blcAssetUploadSizeProperty, Long.class);
if (blcMaxFileSize != null) {
LOG.info(String.format("The %s has been set to %s, using this as the file upload limit and ignoring the Spring Boot settings", blcAssetUploadSizeProperty, blcMaxFileSize));
multipartConfig = new MultipartConfigElement(multipartConfig.getLocation(), multipartConfig.getMaxRequestSize(), blcMaxFileSize, multipartConfig.getFileSizeThreshold());
}
return multipartConfig;
}
use of javax.servlet.MultipartConfigElement in project java-chassis by ServiceComb.
the class TestUploadConfig method getMultipartConfig_config.
@Test
public void getMultipartConfig_config() {
ArchaiusUtils.setProperty(RestConst.UPLOAD_DIR, "upload");
ArchaiusUtils.setProperty(RestConst.UPLOAD_MAX_FILE_SIZE, 1);
ArchaiusUtils.setProperty(RestConst.UPLOAD_MAX_SIZE, 2);
ArchaiusUtils.setProperty(RestConst.UPLOAD_FILE_SIZE_THRESHOLD, 3);
UploadConfig uploadConfig = new UploadConfig();
MultipartConfigElement multipartConfigElement = uploadConfig.toMultipartConfigElement();
Assert.assertEquals("upload", uploadConfig.getLocation());
Assert.assertEquals(1, uploadConfig.getMaxFileSize());
Assert.assertEquals(2, uploadConfig.getMaxSize());
Assert.assertEquals(3, uploadConfig.getFileSizeThreshold());
Assert.assertEquals("upload", multipartConfigElement.getLocation());
Assert.assertEquals(1, multipartConfigElement.getMaxFileSize());
Assert.assertEquals(2, multipartConfigElement.getMaxRequestSize());
Assert.assertEquals(3, multipartConfigElement.getFileSizeThreshold());
}
use of javax.servlet.MultipartConfigElement in project java-chassis by ServiceComb.
the class TestUploadConfig method getMultipartConfig_default.
@Test
public void getMultipartConfig_default() {
ArchaiusUtils.setProperty(RestConst.UPLOAD_DIR, "upload");
UploadConfig uploadConfig = new UploadConfig();
MultipartConfigElement multipartConfigElement = uploadConfig.toMultipartConfigElement();
Assert.assertEquals("upload", uploadConfig.getLocation());
Assert.assertEquals(-1L, uploadConfig.getMaxFileSize());
Assert.assertEquals(-1L, uploadConfig.getMaxSize());
Assert.assertEquals(0, uploadConfig.getFileSizeThreshold());
Assert.assertEquals("upload", multipartConfigElement.getLocation());
Assert.assertEquals(-1L, multipartConfigElement.getMaxFileSize());
Assert.assertEquals(-1L, multipartConfigElement.getMaxRequestSize());
Assert.assertEquals(0, multipartConfigElement.getFileSizeThreshold());
}
Aggregations