org.springframework.util.unit.DataUnit Java Examples

The following examples show how to use org.springframework.util.unit.DataUnit. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MultipartConfig.java    From springboot-link-admin with Apache License 2.0 7 votes vote down vote up
@Bean
public MultipartConfigElement multipartConfigElement() {
	MultipartConfigFactory factory = new MultipartConfigFactory();
	// 单个文件最大
	factory.setMaxFileSize(DataSize.of(100, DataUnit.MEGABYTES)); // 100MB
	// / 设置总上传数据总大小
	factory.setMaxRequestSize(DataSize.of(100, DataUnit.MEGABYTES));// 100MB
	return factory.createMultipartConfig();
}
 
Example #2
Source File: RequestHeaderSizeGatewayFilterFactoryTest.java    From spring-cloud-gateway with Apache License 2.0 5 votes vote down vote up
@Bean
public RouteLocator testRouteLocator(RouteLocatorBuilder builder) {
	return builder.routes().route("test_request_header_size",
			r -> r.order(-1).host("**.test.org").filters(
					f -> f.setRequestHeaderSize(DataSize.of(46L, DataUnit.BYTES)))
					.uri(uri))
			.build();
}
 
Example #3
Source File: RequestHeaderSizeGatewayFilterFactory.java    From spring-cloud-gateway with Apache License 2.0 4 votes vote down vote up
private static String getErrorMessage(Long currentRequestSize, DataSize maxSize) {
	return String.format(ERROR, DataSize.of(currentRequestSize, DataUnit.BYTES),
			maxSize);
}