@org.junit.Test
public void upTest(){
File file = new File("/Users/smile/subl3");
String ak = "**";
String sk = "**";
Auth auth = Auth.create(ak, sk);
UploadManager uploadManager = new UploadManager();
String token = auth.uploadToken("atest", "sub-retur34", 518400, new StringMap()
.put("callbackUrl","http://172.30.249.43:8080/test.php")
.put("callbackBody","filename=$(fname)&filesize=$(fsize)&price=$(x:price)") // 设置callbackBody自定义变量
.put("returnBody","$(x:price)") //设置 returnBody 自定义变量
);
try {
Response res = uploadManager.put(file, "sub-retur34", token,new StringMap()
.put("x:price","pipi")//给自定义变量赋值
,null,false);
System.out.println(res.toString());
System.out.print(res.bodyString());
} catch (QiniuException e) {
Response re = e.response;
System.out.println(re.toString());
}
}