|
@@ -19,6 +19,8 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+
|
|
|
/**
|
|
|
* @Description: 文件上传服务接口实现
|
|
|
* @author: gaodm
|
|
@@ -35,14 +37,17 @@ public class UploadServiceImpl implements UploadService {
|
|
|
if (file.isEmpty()) {
|
|
|
return new FileDTO("FAILURE", "文件不能为空");
|
|
|
}
|
|
|
- //文件大小上限1M
|
|
|
- if (file.getSize() > 1024 * 1024) {
|
|
|
- return new FileDTO("FAILURE", "文件上传失败,超出大小限制1MB");
|
|
|
+ //文件大小上限500M
|
|
|
+ if (file.getSize() > 1024 * 1024 * 500) {
|
|
|
+ return new FileDTO("FAILURE", "文件上传失败,超出大小限制500MB");
|
|
|
}
|
|
|
|
|
|
String result = "";
|
|
|
try {
|
|
|
- OkHttpClient httpClient = new OkHttpClient();
|
|
|
+ OkHttpClient httpClient = new OkHttpClient.Builder()
|
|
|
+ .connectTimeout(500, TimeUnit.SECONDS)
|
|
|
+ .readTimeout(500, TimeUnit.SECONDS)
|
|
|
+ .build();
|
|
|
MultipartBody multipartBody = new MultipartBody.Builder().
|
|
|
setType(MultipartBody.FORM)
|
|
|
.addFormDataPart("file", file.getOriginalFilename(),
|