Skip to content

Commit

Permalink
doc(文件上传): 文件上传方法重载
Browse files Browse the repository at this point in the history
  • Loading branch information
lqyan committed Jul 25, 2024
1 parent 79a73fe commit 8ed0c93
Showing 1 changed file with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -214,6 +217,55 @@ public void uploadFile(String username, InputStream is, String fileName, String
uploadFile(username, is, fileName, uploadPath, null);
}

/**
* @param username 用户名
* @param path 本地文件路径
* @param fileName 文件名
* @param uploadPath 上传路径,服务器路径
* @param isCover 是否覆盖(非必填,默认:false)
*/
public void uploadFile(String username, String path, String fileName, String uploadPath, Boolean isCover) throws FileNotFoundException {
if (StringUtils.isBlank(path)) {
throw new ArgsException("path是必填参数");
}
File file = new File(path);
FileInputStream fileInputStream = new FileInputStream(file);
uploadFile(username, fileInputStream, fileName, uploadPath, isCover);
}


/**
* @param username 用户名
* @param path 本地文件路径
* @param fileName 文件名
* @param uploadPath 上传路径,服务器路径
*/
public void uploadFile(String username, String path, String fileName, String uploadPath) throws FileNotFoundException {
uploadFile(username, path, fileName, uploadPath, null);
}


/**
* @param username 用户名
* @param path 本地文件路径
* @param uploadPath 上传路径,服务器路径
* @param isCover 是否覆盖(非必填,默认:false)
*/
public void uploadFile(String username, String path, String uploadPath, Boolean isCover) throws FileNotFoundException {
File file = new File(path);
uploadFile(username, path, file.getName(), uploadPath, isCover);
}

/**
* @param username 用户名
* @param path 本地文件路径
* @param uploadPath 上传路径,服务器路径
*/
public void uploadFile(String username, String path, String uploadPath) throws FileNotFoundException {
File file = new File(path);
uploadFile(username, path, file.getName(), uploadPath, null);
}


/**
* 获取文件下载地址
Expand Down

0 comments on commit 8ed0c93

Please sign in to comment.