优化下载功能

This commit is contained in:
qitz
2023-11-04 18:32:21 +08:00
parent 37717366ab
commit 2bbc030c40
3 changed files with 38 additions and 9 deletions
@@ -80,6 +80,7 @@ public class FileTransformation {
* @return
*/
public static boolean downLoadFileByUrl(String httpUrl, String dir) throws EsignDemoException {
boolean downLoadFileFlag = false;
InputStream fis = null;
FileOutputStream fileOutputStream = null;
try {
@@ -95,10 +96,17 @@ public class FileTransformation {
while ((length = fis.read(buffer, 0, 1024)) != -1) {
fileOutputStream.write(buffer, 0, length);
}
downLoadFileFlag = true;
System.out.println("下载签署裁决书,downLoadFileFlag:--------------" +downLoadFileFlag);
} catch (IOException e) {
EsignDemoException ex = new EsignDemoException("获取文件流异常", e);
ex.initCause(e);
throw ex;
System.out.println("下载签署裁决书,downLoadFileFlag:--------------" +downLoadFileFlag);
return downLoadFileFlag;
} finally {
try {
if (fis != null) {
@@ -110,10 +118,13 @@ public class FileTransformation {
} catch (IOException e) {
EsignDemoException ex = new EsignDemoException("关闭文件流异常", e);
ex.initCause(e);
throw ex;
System.out.println("下载签署裁决书,downLoadFileFlag:--------------" +downLoadFileFlag);
return downLoadFileFlag;
}
}
return true;
return downLoadFileFlag;
}
@@ -85,6 +85,8 @@ public class SaaSAPIFileUtils {
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr,requestType , jsonParm, header,true);
}
public static void main(String[] args) throws EsignDemoException {
String filePath = "D:\\home\\ruoyi\\uploadPath\\upload\\2023\\10\\7\\23893bfd3f2249ffa5c82850c11c482e.docx";
EsignHttpResponse uploadUrl = getUploadUrl(filePath);