mirror of
https://github.com/yanlongqi/jhinno-openapi-java-sdk.git
synced 2026-03-22 06:15:10 +08:00
Compare commits
1 Commits
release-2.
...
fix-config
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e97ff288f1 |
@@ -180,8 +180,9 @@ public class JHFileApiExecution implements JHApiExecution {
|
|||||||
* @param fileName 文件名称
|
* @param fileName 文件名称
|
||||||
* @param uploadPath 上传路径
|
* @param uploadPath 上传路径
|
||||||
* @param isCover 是否覆盖(非必填,默认:false)
|
* @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) {
|
if (is == null) {
|
||||||
throw new ArgsException("is是必填参数");
|
throw new ArgsException("is是必填参数");
|
||||||
}
|
}
|
||||||
@@ -193,6 +194,9 @@ public class JHFileApiExecution implements JHApiExecution {
|
|||||||
if (isCover != null) {
|
if (isCover != null) {
|
||||||
body.put("isCover", isCover);
|
body.put("isCover", isCover);
|
||||||
}
|
}
|
||||||
|
if (StringUtils.isNotBlank(fileConf)) {
|
||||||
|
body.put("fileConf", fileConf);
|
||||||
|
}
|
||||||
body.put("uploadPath", uploadPath);
|
body.put("uploadPath", uploadPath);
|
||||||
ResponseResult<Object> result = execution.getJhApiClient().upload(
|
ResponseResult<Object> result = execution.getJhApiClient().upload(
|
||||||
FilePathConstant.FILE_UPLOAD_PATH,
|
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>
|
* <p>
|
||||||
@@ -224,6 +245,8 @@ public class JHFileApiExecution implements JHApiExecution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 上传一个本地的路径
|
||||||
|
*
|
||||||
* @param username 用户名
|
* @param username 用户名
|
||||||
* @param path 本地文件路径
|
* @param path 本地文件路径
|
||||||
* @param fileName 文件名
|
* @param fileName 文件名
|
||||||
@@ -241,6 +264,11 @@ public class JHFileApiExecution implements JHApiExecution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 上传一个本地的路径(不覆盖源文件)
|
||||||
|
* <p>
|
||||||
|
* 源文件目录下存在相同文件则会报错
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* @param username 用户名
|
* @param username 用户名
|
||||||
* @param path 本地文件路径
|
* @param path 本地文件路径
|
||||||
* @param fileName 文件名
|
* @param fileName 文件名
|
||||||
@@ -252,6 +280,8 @@ public class JHFileApiExecution implements JHApiExecution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 上传一个本地的路径
|
||||||
|
*
|
||||||
* @param username 用户名
|
* @param username 用户名
|
||||||
* @param path 本地文件路径
|
* @param path 本地文件路径
|
||||||
* @param uploadPath 上传路径,服务器路径
|
* @param uploadPath 上传路径,服务器路径
|
||||||
@@ -264,6 +294,8 @@ public class JHFileApiExecution implements JHApiExecution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 上传一个本地的路径(不覆盖源文件)
|
||||||
|
*
|
||||||
* @param username 用户名
|
* @param username 用户名
|
||||||
* @param path 本地文件路径
|
* @param path 本地文件路径
|
||||||
* @param uploadPath 上传路径,服务器路径
|
* @param uploadPath 上传路径,服务器路径
|
||||||
@@ -382,7 +414,7 @@ public class JHFileApiExecution implements JHApiExecution {
|
|||||||
* @param compressType 压缩类型 (未使用以后扩展)
|
* @param compressType 压缩类型 (未使用以后扩展)
|
||||||
*/
|
*/
|
||||||
public void uncompress(String username, String sourceFilePath, String targetDirPath, Boolean isCover,
|
public void uncompress(String username, String sourceFilePath, String targetDirPath, Boolean isCover,
|
||||||
String password, String compressType) {
|
String password, String compressType) {
|
||||||
if (StringUtils.isBlank(sourceFilePath)) {
|
if (StringUtils.isBlank(sourceFilePath)) {
|
||||||
throw new ArgsException("sourceFilePath不能为空!");
|
throw new ArgsException("sourceFilePath不能为空!");
|
||||||
}
|
}
|
||||||
@@ -415,7 +447,7 @@ public class JHFileApiExecution implements JHApiExecution {
|
|||||||
* @param password 密码
|
* @param password 密码
|
||||||
*/
|
*/
|
||||||
public void uncompress(String username, String sourceFilePath, String targetDirPath, Boolean isCover,
|
public void uncompress(String username, String sourceFilePath, String targetDirPath, Boolean isCover,
|
||||||
String password) {
|
String password) {
|
||||||
uncompress(username, sourceFilePath, targetDirPath, isCover, password, null);
|
uncompress(username, sourceFilePath, targetDirPath, isCover, password, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,14 +27,14 @@ public class JHClientConfig {
|
|||||||
public static final JHApiExecutionManage API_EXECUTRON_MANAGE = new JHApiExecutionManage(
|
public static final JHApiExecutionManage API_EXECUTRON_MANAGE = new JHApiExecutionManage(
|
||||||
"https://192.168.87.24");
|
"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 {
|
static {
|
||||||
API_EXECUTRON_MANAGE.configureApiExecution(t -> {
|
API_EXECUTRON_MANAGE.configureApiExecution(t -> {
|
||||||
// 默认为使用Token模式,如何使用的Token模式,则不需要配置ACCESS_KEY和ACCESS_KEY SECRET
|
// 默认为使用Token模式,如何使用的Token模式,则不需要配置ACCESS_KEY和ACCESS_KEY SECRET
|
||||||
// t.setAuthType(AuthType.ACCESS_KEY);
|
t.setAuthType(AuthType.ACCESS_SECRET_MODE);
|
||||||
t.setAccessKey(ACCESS_KEY);
|
t.setAccessKey(ACCESS_KEY);
|
||||||
t.setAccessKeySecret(ACCESS_KEY_SECRET);
|
t.setAccessKeySecret(ACCESS_KEY_SECRET);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -92,9 +92,20 @@ public class FileApiTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testUploadFileNoCover() throws IOException {
|
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);
|
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