import com.qiniu.common.QiniuException;
import com.qiniu.http.Response;
import com.qiniu.storage.Configuration;
import com.qiniu.storage.Region;
import com.qiniu.storage.UploadManager;
import com.qiniu.util.Auth;
import com.qiniu.util.StringMap;


public class UploadBySelfDefiningParam {

    private static final String ACCESS_KEY = "设置好你们自己的AK";
    private static final String SECRET_KEY = "设置好你们自己的SK";
    private static final Auth auth = Auth.create(ACCESS_KEY, SECRET_KEY);

    private Configuration cfg;
    private UploadManager uploadManager;
    private Region region;
    private String bucket;

    {
        bucket = "设置你们自己的上传空间名称";
        //指定存储空间所在区域，华北region1，华南region2 ，华东 region0
        region = Region.region1();
        //初始化cfg实例，可以指定上传区域，也可以创建无参实例 , cfg = new Configuration();
        cfg = new Configuration(region);
        //是否指定https上传，默认true
        //cfg.useHttpsDomains=false;
        //构建 uploadManager 实例
        uploadManager = new UploadManager(cfg);
    }

    public static void main(String args[]) throws Exception {
        UploadBySelfDefiningParam up = new UploadBySelfDefiningParam();
        up.upload();
    }

    public void upload() throws QiniuException {
        //设置上传后的文件名称
        String key = "qiniu_test.jpg";
        //上传策略
        StringMap policy = new StringMap();
        //自定义上传后返回内容，返回自定义参数，需要设置 x:参数名称
        policy.put("returnBody", "{\"key\":\"$(key)\",\"hash\":\"$(etag)\",\"fname\":\"$(x:fname)\",\"age\",$(x:age)}");
        //生成上传token
        String upToken = auth.uploadToken(bucket, key, 3600, policy);

        //上传自定义参数，自定义参数名称需要以 x:开头
        StringMap params = new StringMap();
        params.put("x:fname","123.jpg");
        params.put("x:age",20);
        String localFilePath = "/Users/mini/Downloads/qiniu_test.jpg";

        Response response = uploadManager.put(localFilePath, key, upToken,params,null,false);
        //输出返回结果
        System.out.println(response.bodyString());
    }

}

@@ -240,16 +240,272 @@
 ngMap;%0A%0A
+/**%0A * %E8%AE%BE%E7%BD%AE%E8%87%AA%E5%AE%9A%E4%B9%89%E5%8F%98%E9%87%8F%E4%B8%8A%E4%BC%A0%E5%B9%B6%E6%8E%A5%E6%94%B6%E8%87%AA%E5%AE%9A%E4%B9%89%E5%8F%98%E9%87%8F demo%0A *%0A * %E4%B8%8A%E4%BC%A0%E6%90%BA%E5%B8%A6%E8%87%AA%E5%AE%9A%E4%B9%89%E5%8F%98%E9%87%8F%E5%8F%82%E8%80%83%E6%96%87%E6%A1%A3%0A * https://developer.qiniu.com/kodo/manual/1235/vars#2%0A *%0A * %E6%8E%A5%E6%94%B6%E8%87%AA%E5%AE%9A%E4%B9%89%E5%8F%98%E9%87%8F%E5%8F%82%E8%80%83%E4%B8%8A%E4%BC%A0%E7%AD%96%E7%95%A5%E6%96%87%E6%A1%A3 -- returnBody%0A * https://developer.qiniu.com/kodo/manual/1206/put-policy%0A *%0A * %E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%85%B7%E4%BD%93%E7%94%A8%E6%B3%95%E5%AE%9E%E4%BE%8B%E5%8F%82%E8%80%83 UploadBySelfDefiningParam.upload()%0A */
 %0Apublic 

add comment for UploadBySelfDefiningParam to upload file with self define params [ci skip]