mirror of
https://github.com/yanlongqi/jhinno-openapi-java-sdk.git
synced 2026-03-22 06:15:10 +08:00
@@ -180,8 +180,9 @@ public class JHFileApiExecution implements JHApiExecution {
|
||||
* @param fileName 文件名称
|
||||
* @param uploadPath 上传路径
|
||||
* @param isCover 是否覆盖(非必填,默认:false)
|
||||
* @param fileConf 密级(只有开启了密级才需要此参数,可以是密级的中文名,也可以是密级的中文名、英文名、或者密级的key)
|
||||
*/
|
||||
public void uploadFile(String username, InputStream is, String fileName, String uploadPath, Boolean isCover) {
|
||||
public void uploadFile(String username, InputStream is, String fileName, String uploadPath, Boolean isCover, String fileConf) {
|
||||
if (is == null) {
|
||||
throw new ArgsException("is是必填参数");
|
||||
}
|
||||
@@ -193,6 +194,9 @@ public class JHFileApiExecution implements JHApiExecution {
|
||||
if (isCover != null) {
|
||||
body.put("isCover", isCover);
|
||||
}
|
||||
if (StringUtils.isNotBlank(fileConf)) {
|
||||
body.put("fileConf", fileConf);
|
||||
}
|
||||
body.put("uploadPath", uploadPath);
|
||||
ResponseResult<Object> result = execution.getJhApiClient().upload(
|
||||
FilePathConstant.FILE_UPLOAD_PATH,
|
||||
@@ -208,6 +212,23 @@ public class JHFileApiExecution implements JHApiExecution {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
* <p>
|
||||
* 如果isCover为空或者为false,源文件目录下存在相同文件则会报错
|
||||
* </p>
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param is 文件流
|
||||
* @param fileName 文件名称
|
||||
* @param uploadPath 上传路径
|
||||
* @param isCover 是否覆盖(非必填,默认:false)
|
||||
*/
|
||||
public void uploadFile(String username, InputStream is, String fileName, String uploadPath, Boolean isCover) {
|
||||
uploadFile(username, is, fileName, uploadPath, isCover, null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传文件(不覆盖源文件)
|
||||
* <p>
|
||||
@@ -224,6 +245,8 @@ public class JHFileApiExecution implements JHApiExecution {
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传一个本地的路径
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param path 本地文件路径
|
||||
* @param fileName 文件名
|
||||
@@ -241,6 +264,11 @@ public class JHFileApiExecution implements JHApiExecution {
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传一个本地的路径(不覆盖源文件)
|
||||
* <p>
|
||||
* 源文件目录下存在相同文件则会报错
|
||||
* </p>
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param path 本地文件路径
|
||||
* @param fileName 文件名
|
||||
@@ -252,6 +280,8 @@ public class JHFileApiExecution implements JHApiExecution {
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传一个本地的路径
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param path 本地文件路径
|
||||
* @param uploadPath 上传路径,服务器路径
|
||||
@@ -264,6 +294,8 @@ public class JHFileApiExecution implements JHApiExecution {
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传一个本地的路径(不覆盖源文件)
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param path 本地文件路径
|
||||
* @param uploadPath 上传路径,服务器路径
|
||||
@@ -311,7 +343,7 @@ public class JHFileApiExecution implements JHApiExecution {
|
||||
|
||||
/**
|
||||
* 获取文件输入流
|
||||
*
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param filePath 文件路径
|
||||
* @return 文件流
|
||||
@@ -323,7 +355,7 @@ public class JHFileApiExecution implements JHApiExecution {
|
||||
|
||||
/**
|
||||
* 获取文件输入流
|
||||
*
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param filePath 文件路径
|
||||
* @param forceDownload 是否强制下载,打开密级之后未标密的文件无法下载,可以通过设置当前参数为true来强制下载,默认:false
|
||||
@@ -382,7 +414,7 @@ public class JHFileApiExecution implements JHApiExecution {
|
||||
* @param compressType 压缩类型 (未使用以后扩展)
|
||||
*/
|
||||
public void uncompress(String username, String sourceFilePath, String targetDirPath, Boolean isCover,
|
||||
String password, String compressType) {
|
||||
String password, String compressType) {
|
||||
if (StringUtils.isBlank(sourceFilePath)) {
|
||||
throw new ArgsException("sourceFilePath不能为空!");
|
||||
}
|
||||
@@ -415,7 +447,7 @@ public class JHFileApiExecution implements JHApiExecution {
|
||||
* @param password 密码
|
||||
*/
|
||||
public void uncompress(String username, String sourceFilePath, String targetDirPath, Boolean isCover,
|
||||
String password) {
|
||||
String password) {
|
||||
uncompress(username, sourceFilePath, targetDirPath, isCover, password, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,14 +27,14 @@ public class JHClientConfig {
|
||||
public static final JHApiExecutionManage API_EXECUTRON_MANAGE = new JHApiExecutionManage(
|
||||
"https://192.168.87.24");
|
||||
|
||||
public static final String ACCESS_KEY = "3f03747f147942bd8debd81b6c9c6a80";
|
||||
public static final String ACCESS_KEY = "e2544957e53b4377bb4f8203a094e50b";
|
||||
|
||||
public static final String ACCESS_KEY_SECRET = "e0681859b91c499eb1d2c8e09cea3242";
|
||||
public static final String ACCESS_KEY_SECRET = "52d18cf7163047b78ea48756b8b40d28";
|
||||
|
||||
static {
|
||||
API_EXECUTRON_MANAGE.configureApiExecution(t -> {
|
||||
// 默认为使用Token模式,如何使用的Token模式,则不需要配置ACCESS_KEY和ACCESS_KEY SECRET
|
||||
// t.setAuthType(AuthType.ACCESS_KEY);
|
||||
t.setAuthType(AuthType.ACCESS_SECRET_MODE);
|
||||
t.setAccessKey(ACCESS_KEY);
|
||||
t.setAccessKeySecret(ACCESS_KEY_SECRET);
|
||||
});
|
||||
|
||||
@@ -92,9 +92,20 @@ public class FileApiTest {
|
||||
*/
|
||||
@Test
|
||||
public void testUploadFileNoCover() throws IOException {
|
||||
File file = new File("C:\\Users\\yanlongqi\\Desktop\\双色球.xls");
|
||||
File file = new File("C:\\Users\\yanlongqi\\Desktop\\Hash.exe");
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
execution.uploadFile("jhadmin", fileInputStream, file.getName(), "$HOME/temp");
|
||||
execution.uploadFile("lqyan", fileInputStream, file.getName(), "$HOME/temp");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 测试上传文件,开启密级的情况
|
||||
*/
|
||||
@Test
|
||||
public void testUploadFileConf() throws IOException {
|
||||
File file = new File("C:\\Users\\yanlongqi\\Desktop\\Hash.exe");
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
execution.uploadFile("lqyan", fileInputStream, file.getName(), "$HOME/temp111", false,"public");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user