参数填写指南
请求参数(header):
参数填写指南| 参数名 | 必填 | 描述 | 默认值 |
|---|---|---|---|
| Content-Type | 是 | 请求体数据类型 | application/json |
| usercode | 是 | 用户 | |
| password | 是 | 密码 | |
| billid | 否 | 单据主键(上传凭证附件时,必传,传凭证PK) | |
| billtype | 否 | 单据类型(上传凭证附件时,必传,传“voucher”) | |
| creator | 否 | 上传人(直接写用户编码) | |
| filelength | 否 | 文件大小 | |
| filename | 否 | 文件名称 | |
| parentpath | 否 | 附件路径(单据主键/文件夹名称/) | 如果报异常 invalid stream header: 7B0A2020,那就把这个参数名换成path |
| system | 是 | 系统参数 |
请求参数(body):
| 参数名 | 类型 | 是否数组 | 必填 | 描述 | 默认值 |
|---|
返回类型参数:
| 参数名 | 类型 | 是否数组 | 必填 | 描述 | 默认值 |
|---|
代码示例:
请求参数示例:
复制代码
import java.io.File;
import java.io.FileInputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
public class testfile {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ObjectInputStream ois = null;
ObjectOutputStream oos = null;
try {
URL url = new URL("http://127.0.0.1:80/u8cloud/api/file/upload");
URLConnection conn = url.openConnection();
if (conn instanceof HttpURLConnection) {
((HttpURLConnection) conn).setChunkedStreamingMode(2048);
}
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setRequestProperty("content-type",
"application/x-java-serialized-object,charset=utf-8");
byte[] buf = new byte[2048];
int len = -1;
File file = new File("D:\\home\\u8c_v27_home\\api\\config\\arap.config");
//必须以单据主键开头,要不然文档管理查看不到
conn.setRequestProperty("parentpath", "1001ZZ10000000003QA2/136/345");
conn.setRequestProperty("filename", "arap.config");
conn.setRequestProperty("creator", "18210083662");
conn.setRequestProperty("filelength", file.length() + "");
conn.setRequestProperty("system", "test");
conn.setRequestProperty("usercode","1821006");
conn.setRequestProperty("password", "test");
oos = new ObjectOutputStream(conn.getOutputStream());
FileInputStream input = new FileInputStream(file);
while ((len = input.read(buf)) != -1) {
oos.write(buf, 0, len);
}
oos.flush();
oos.close();
ois = new ObjectInputStream(conn.getInputStream());
Object obj = ois.readObject();
if (obj instanceof Exception) {
throw (Exception) obj;
}
} catch(Exception e1){
}finally {
try {
if (oos != null) {
oos.close();
}
if (ois != null) {
ois.close();
}
} catch (Exception e2) {
}
}
}
}正确返回示例:
复制代码
{
"status": "success"
}错误返回示例:
复制代码
{
"status": "falied",
"errorcode": "",
"errormsg": "U8C返回信息:java.lang.Exception: 文件已经存在:arap.config"
}