七牛存储java-sdk设置 callbackBody,returnBody 自定义变量

    @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());
        }
    }
    原文作者:三木
    原文地址: https://segmentfault.com/a/1190000006196899
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞