七牛java自定义变量和fname测试(returnbody,callbackbody同理)

注意:callbackbody是查询字符的格式用&链接。

1,自定义变量

public String getUpToken33(){
        return auth.uploadToken("javademo", null, 3600, new StringMap()
             .put("returnBody","{\"key\":\"$(key)\",\"foo\":\"$(x:foo)\"}"));
    }

Response res = uploadManager.put(imgFile, "vvvv", getUpToken33(), new StringMap().put("x:foo", "fooll"),null,false);

结果:

{"key":"vvvv.key","foo":"fooll"}

2,fname(如果断点续传是获取不到的,不过后期服务端会支持断点后同样能获取到)

public String getUpToken33(){
        return auth.uploadToken("javademo", null, 3600, new StringMap()
             .put("returnBody","{\"key\":\"$(key)\",\"foo\":\"$(x:foo)\",\"name\":\"$(fname)\",\"test\":\"$(x:test)\"}"));
    }
Response res = uploadManager.put(imgFile, "vvvv.key", getUpToken33(), new StringMap().put("x:foo", "fooll").put("x:test", "test111"),null,false);

结果:

{"key":"vvvv.key","foo":"fooll","name":"vvvv.key","test":"test111"}

3,设置callbackbody中的一些常量

public String getUpToken33(){
        return auth.uploadToken("javademo", null, 3600, new StringMap()
             .put("returnBody","{\"key\":\"$(key)\",\"foo\":\"$(x:foo)\",\"name\":\"$(fname)\",\"test\":\"$(x:test)\",\"uid\":123}"));

结果:

{"key":"vvvv.key","foo":"fooll","name":"vvvv.key","test":"test111","uid":123}

4,如果遇到返回的信息不是客户端带过去的,而是callbackbody中的字符。那么肯定是callbackbody的格式不对.

例如自定义变量写为常量。这都是有可能的。

你可能感兴趣的:(七牛java自定义变量和fname测试(returnbody,callbackbody同理))