|
@@ -88,25 +88,6 @@ public class AttachmentFileUtil {
|
|
logger.info("FTP inputStream -- size:"+inputStream.available());
|
|
logger.info("FTP inputStream -- size:"+inputStream.available());
|
|
System.out.println("inputStream:"+inputStream);
|
|
System.out.println("inputStream:"+inputStream);
|
|
|
|
|
|
- // outStream = new ByteArrayOutputStream();
|
|
|
|
- // byte[] buffer = new byte[1024];
|
|
|
|
- // int len = 0;
|
|
|
|
- // while( (len = inputStream.read(buffer)) != -1 ){
|
|
|
|
- // outStream.write(buffer, 0, len);
|
|
|
|
- // }
|
|
|
|
- // byte[] bt = outStream.toByteArray();
|
|
|
|
-
|
|
|
|
- // if(null != bt && bt.length > 0){
|
|
|
|
- // DecimalFormat df = new DecimalFormat("#");
|
|
|
|
- // size = Integer.parseInt(df.format((double) bt.length));
|
|
|
|
-
|
|
|
|
- // System.out.println("文件大小=:" + size);
|
|
|
|
- // }else{
|
|
|
|
- // System.out.println("没有从该连接获得内容");
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // attachItem.put("size", size);
|
|
|
|
-// 苍穹自带
|
|
|
|
TempFileCache cache = CacheFactory.getCommonCacheFactory().getTempFileCache();
|
|
TempFileCache cache = CacheFactory.getCommonCacheFactory().getTempFileCache();
|
|
tempUrl = cache.saveAsFullUrl((String) attachItem.get("name"), inputStream, 1600);
|
|
tempUrl = cache.saveAsFullUrl((String) attachItem.get("name"), inputStream, 1600);
|
|
logger.info("FTP tempUrl -- inputStream -- size:" + CacheFactory.getCommonCacheFactory().getTempFileCache().getInputStream(tempUrl).available());
|
|
logger.info("FTP tempUrl -- inputStream -- size:" + CacheFactory.getCommonCacheFactory().getTempFileCache().getInputStream(tempUrl).available());
|
|
@@ -156,12 +137,19 @@ public class AttachmentFileUtil {
|
|
FileItem fileItem = new FileItem(fileName, pathParam, in);
|
|
FileItem fileItem = new FileItem(fileName, pathParam, in);
|
|
|
|
|
|
//从临时上传至 文件服务器
|
|
//从临时上传至 文件服务器
|
|
- String downUrl =service.upload(fileItem);
|
|
|
|
|
|
+ String downUrl = service.upload(fileItem);
|
|
logger.info("FTP downUrl:"+downUrl);
|
|
logger.info("FTP downUrl:"+downUrl);
|
|
System.out.println("downUrl:"+downUrl);
|
|
System.out.println("downUrl:"+downUrl);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 附件有2个地址
|
|
|
|
+ * 一个是 downloadID 示例:1ebecb8a91003c00
|
|
|
|
+ * 一个是 url 示例:http://192.168.1.1/1ebecb8a91003c00
|
|
|
|
+ */
|
|
|
|
+ attachItem.put("downUrl", downUrl);
|
|
attachItem.put("url", actUrl);
|
|
attachItem.put("url", actUrl);
|
|
result.put("url", actUrl);
|
|
result.put("url", actUrl);
|
|
|
|
+ result.put("downUrl", downUrl);
|
|
attachments.add(attachItem);
|
|
attachments.add(attachItem);
|
|
//绑定单据
|
|
//绑定单据
|
|
AttachmentServiceHelper.upload(entity, pk, attachKey, attachments);
|
|
AttachmentServiceHelper.upload(entity, pk, attachKey, attachments);
|
|
@@ -233,7 +221,8 @@ public class AttachmentFileUtil {
|
|
attObj.set("name", attachment.get("name"));
|
|
attObj.set("name", attachment.get("name"));
|
|
attObj.set("size", 0);
|
|
attObj.set("size", 0);
|
|
attObj.set("uid", attachment.get("uid"));
|
|
attObj.set("uid", attachment.get("uid"));
|
|
- attObj.set("url", attachment.get("uid"));
|
|
|
|
|
|
+ //attObj.set("url", attachment.get("url"));
|
|
|
|
+ attObj.set("url", attachment.get("downUrl"));
|
|
String fileType = attachment.get("name").toString();
|
|
String fileType = attachment.get("name").toString();
|
|
if (fileType.contains(".")) {
|
|
if (fileType.contains(".")) {
|
|
fileType = fileType.substring(fileType.lastIndexOf(".") + 1);
|
|
fileType = fileType.substring(fileType.lastIndexOf(".") + 1);
|