fix: cap external uploads at 100mb
This commit is contained in:
parent
9a893d9cc0
commit
b7ac08be5d
@ -34,8 +34,6 @@ red-circle:
|
||||
access-url: ${LIKEI_TENCENT_COS_ACCESS_URL}
|
||||
connection-timeout-ms: ${LIKEI_TENCENT_COS_CONNECTION_TIMEOUT_MS:15000}
|
||||
connection-request-timeout-ms: ${LIKEI_TENCENT_COS_CONNECTION_REQUEST_TIMEOUT_MS:15000}
|
||||
socket-timeout-ms: ${LIKEI_TENCENT_COS_SOCKET_TIMEOUT_MS:900000}
|
||||
request-timeout-ms: ${LIKEI_TENCENT_COS_REQUEST_TIMEOUT_MS:900000}
|
||||
shutdown-timeout-ms: ${LIKEI_TENCENT_COS_SHUTDOWN_TIMEOUT_MS:10000}
|
||||
max-error-retry: ${LIKEI_TENCENT_COS_MAX_ERROR_RETRY:0}
|
||||
instant-message:
|
||||
|
||||
@ -31,7 +31,7 @@ import java.util.UUID;
|
||||
public class OssRestController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(OssRestController.class);
|
||||
private static final long MAX_UPLOAD_SIZE_BYTES = 500L * 1024 * 1024;
|
||||
private static final long MAX_UPLOAD_SIZE_BYTES = 100L * 1024 * 1024;
|
||||
|
||||
private final AliYunStsService aliYunStsService;
|
||||
private final OssService ossService;
|
||||
@ -78,7 +78,7 @@ public class OssRestController {
|
||||
return ResultResponse.failure(OssErrorCode.FILE_IS_NULL);
|
||||
}
|
||||
if (file.getSize() > MAX_UPLOAD_SIZE_BYTES) {
|
||||
return ResultResponse.failure(OssErrorCode.FILE_SIZE_GREATER_THAN_500M);
|
||||
return ResultResponse.failure(OssErrorCode.FILE_SIZE_GREATER_THAN_100M);
|
||||
}
|
||||
String name = file.getOriginalFilename().toLowerCase();
|
||||
if(!FileUtils.fileContentType(name)) {
|
||||
@ -123,7 +123,7 @@ public class OssRestController {
|
||||
return ResultResponse.failure(OssErrorCode.FILE_IS_NULL);
|
||||
}
|
||||
if (file.getSize() > MAX_UPLOAD_SIZE_BYTES) {
|
||||
return ResultResponse.failure(OssErrorCode.FILE_SIZE_GREATER_THAN_500M);
|
||||
return ResultResponse.failure(OssErrorCode.FILE_SIZE_GREATER_THAN_100M);
|
||||
}
|
||||
String storageKey = buildStorageKey(dir, filename, file.getOriginalFilename());
|
||||
if (tencentCosStorageService.isEnabled()) {
|
||||
|
||||
@ -19,8 +19,8 @@ public class TencentCosProperties {
|
||||
private String accessUrl = "";
|
||||
private int connectionTimeoutMs = 15000;
|
||||
private int connectionRequestTimeoutMs = 15000;
|
||||
private int socketTimeoutMs = 900000;
|
||||
private int requestTimeoutMs = 900000;
|
||||
private int socketTimeoutMs = 120000;
|
||||
private int requestTimeoutMs = 120000;
|
||||
private int shutdownTimeoutMs = 10000;
|
||||
private int maxErrorRetry = 0;
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ import com.red.circle.framework.dto.IResponseErrorCode;
|
||||
public enum OssErrorCode implements IResponseErrorCode {
|
||||
FILE_IS_NULL(20001, "file is null"),
|
||||
FILE_TYPE_NOT_SUPPORTED(20003, "File type not supported"),
|
||||
FILE_SIZE_GREATER_THAN_500M(20003, "File size greater than 500M"),
|
||||
FILE_SIZE_GREATER_THAN_100M(20003, "File size greater than 100M"),
|
||||
NETWORK_ANOMALY(20004, "network anomaly");
|
||||
|
||||
private final int code;
|
||||
|
||||
@ -9,7 +9,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
@Configuration
|
||||
public class UndertowUploadLimitConfiguration {
|
||||
|
||||
private static final long MAX_UPLOAD_REQUEST_SIZE_BYTES = 520L * 1024 * 1024;
|
||||
private static final long MAX_UPLOAD_REQUEST_SIZE_BYTES = 105L * 1024 * 1024;
|
||||
|
||||
@Bean
|
||||
public WebServerFactoryCustomizer<ConfigurableUndertowWebServerFactory> undertowUploadLimitCustomizer() {
|
||||
|
||||
@ -2,7 +2,7 @@ server:
|
||||
port: 3000
|
||||
shutdown: graceful
|
||||
undertow:
|
||||
max-http-post-size: 520MB
|
||||
max-http-post-size: 105MB
|
||||
no-request-timeout: 60000
|
||||
|
||||
spring:
|
||||
@ -12,8 +12,8 @@ spring:
|
||||
allow-bean-definition-overriding: true
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 500MB
|
||||
max-request-size: 520MB
|
||||
max-file-size: 100MB
|
||||
max-request-size: 105MB
|
||||
enabled: true
|
||||
profiles:
|
||||
active: @profiles.active@
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user