Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize and secure temp file creation #4

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.yupi.web.model.entity.User;
import com.yupi.web.model.enums.FileUploadBizEnum;
import com.yupi.web.service.UserService;
import java.nio.file.Files;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.web.bind.annotation.*;
Expand Down Expand Up @@ -59,7 +60,7 @@ public BaseResponse<String> testUploadFile(@RequestPart("file") MultipartFile mu
File file = null;
try {
// 上传文件
file = File.createTempFile(filepath, null);
file = Files.createTempFile(filepath, null).toFile();
multipartFile.transferTo(file);
cosManager.putObject(filepath, file);
// 返回可访问地址
Expand Down Expand Up @@ -135,7 +136,7 @@ public BaseResponse<String> uploadFile(@RequestPart("file") MultipartFile multip
File file = null;
try {
// 上传文件
file = File.createTempFile(filepath, null);
file = Files.createTempFile(filepath, null).toFile();
multipartFile.transferTo(file);
cosManager.putObject(filepath, file);
// 返回可访问地址
Expand Down