外部系统通过调用上传接口,可以把外部系统需要上传到的附件先通过此接口完成,如外边系统发起表单流程,需要先调用此接口。
名称
uploadService 文件上传服务。
请求路径:/seeyon/uploadService.do?method= processUploadService
参数:
|
参数 |
数据类型 |
说明 |
|
token |
string |
登录验证后获取的身份令牌。 |
|
senderLoginName |
string |
发起者登录名 |
返回值:string
成功则返回生成的附件id,如果多个文件上传则以"|"符号分割返回
示例:
URL preUrl = null;
URLConnection uc = null;
preUrl = new URL("http://128.2.3.174/seeyon/uploadService.do?
method = processUploadService"
+"&senderLoginName="+"zy"
+"&token="+"997a7cdc-2399-47e8-991e-96c859cccc7f");
String s = parameters.toString();
uc = preUrl.openConnection();
HttpURLConnection hc = (HttpURLConnection) uc;
hc.setDoOutput(true);
hc.setUseCaches(false);
hc.setRequestProperty("contentType", "charset=utf-8");
hc.setRequestMethod("POST");
BufferedInputStream input=new BufferedInputStream(new FileInputStream("c:/LDAP集成设计文档.doc"));
String BOUNDARY = "---------------------------7d4a6d158c9"; // 分隔符
String fileName="LDAP集成设计文档.doc";
StringBuffer sb = new StringBuffer();
sb.append("--");
sb.append(BOUNDARY);
sb.append("\r\n");
sb.append("Content-Disposition: form-data; \r\n name=\"1\"; filename=\""+fileName+"\"\r\n");
sb.append("Content-Type: application/msword\r\n\r\n");
hc.setRequestProperty("Content-Type",
"multipart/form-data;boundary=" + "---------------------------7d4a6d158c9");
byte[] end_data = ("\r\n--" + BOUNDARY + "--\r\n").getBytes();
DataOutputStream dos = new DataOutputStream(hc.getOutputStream());
dos.write(sb.toString().getBytes("utf-8"));
int cc=0;
while((cc=input.read())!=-1)
{
dos.write(cc);
}
dos.write(end_data);
dos.flush();
dos.close();
FileOutputStream file = new FileOutputStream("c:/test.txt");
InputStream is = hc.getInputStream();
int ch;
while ((ch = is.read()) != -1) {
file.write(ch);
}
if (is != null)
is.close();
上传下载本地调用:
import com.seeyon.oainterface.impl.exportdata.FileDownloadExporter
FileDownloadExporter exporter=new FileDownloadExporter();
exporter.processDownload(token, fileId, out);
import com.seeyon.oainterface.impl.exportdata.FileUploadExporter;
FileUploadExporter fileUpload=new FileUploadExporter();
String outStr= fileUpload.processUpload(request);

