BOS开发 上传附加和下载附件

这两个方法是从系统的方法分离出来,修改成自己需要的工具类:

public class AttachmentHelper {
	
	public static void attachmentDownload(String attchID,Component owner)throws Exception{
    	FileGetter fg = new FileGetter((IAttachment)AttachmentFactory.getRemoteInstance(), AttachmentFtpFacadeFactory.getRemoteInstance());
    	fg.downloadAttachment(attchID,owner);	
	}
	
	public static String attachmentUpload(Component owner)throws Exception{
		boolean isEdit = true;
		AttachmentClientManager attachmentClientManager = AttachmentManagerFactory
				.getClientManager();

		String attachMentTempID = null;
		AttachmentUIContextInfo info = null;
		if (info == null)
			info = new AttachmentUIContextInfo();
		if ((info.getBoID() == null) || (info.getBoID().trim().equals(""))) {
			String boID = attachmentClientManager.getAttID().toString();
			info.setBoID(boID);
		}
		info.setEdit(isEdit);
		attachmentClientManager.showUploadFilesUI(owner, info);
		if ((attachmentClientManager.attachmentID != null)
				&& (attachmentClientManager.attachmentID.length > 0)) {
			//start 这段函数其实好像没用到
			List list = new ArrayList();
			for (int i = 0; i < attachmentClientManager.attachmentID.length; ++i) {
				if (!(StringUtils
						.isEmpty(attachmentClientManager.attachmentID[i]))) {
					list.add(attachmentClientManager.attachmentID[i]);
				}
			}
			//end
			return attachmentClientManager.attachmentID[0];
		}
		return null;
	}

}

有很多多余的东西,可以根据需要修改

发布了35 篇原创文章 · 获赞 19 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/m0_37628958/article/details/82981574