赞
踩
这种方式 KEY 值相同 会报 File already exist
public Object createToken(FileModel record,Boolean openCallBack ) throws Exception {
Config.ACCESS_KEY = AppConfig.getInstance().getQiniuAccessKey();
Config.SECRET_KEY = AppConfig.getInstance().getQiniuSecretKey();
mac = new Mac(Config.ACCESS_KEY, Config.SECRET_KEY);
AppConfig.getInstance().setQiniuBucketName(record.getBucketType());
putPolicy = new PutPolicy(AppConfig.getInstance().getQiniuBucketName());
putPolicy.saveKey = createSaveKey(record);
putPolicy.callbackUrl=createCallbackUrl(record.getOpenCallBack());
putPolicy.callbackBody=createCallbackBody(record);
putPolicy.returnBody=createReturnBody(record);
uptoken = putPolicy.token(mac);
TokenModel obj=new TokenModel();
obj.setUptoken(uptoken);
return obj;
}
这种方式 KEY 值相同 bad token
public Object createToken(FileModel record,Boolean openCallBack ) throws Exception {
Config.ACCESS_KEY = AppConfig.getInstance().getQiniuAccessKey();
Config.SECRET_KEY = AppConfig.getInstance().getQiniuSecretKey();
mac = new Mac(Config.ACCESS_KEY, Config.SECRET_KEY);
AppConfig.getInstance().setQiniuBucketName(record.getBucketType());
//假如我上传test.png key 也是test.png
putPolicy = new PutPolicy(AppConfig.getInstance().getQiniuBucketName()+":test.png");
putPolicy.saveKey = createSaveKey(record);
putPolicy.callbackUrl=createCallbackUrl(record.getOpenCallBack());
putPolicy.callbackBody=createCallbackBody(record);
putPolicy.returnBody=createReturnBody(record);
uptoken = putPolicy.token(mac);
TokenModel obj=new TokenModel();
obj.setUptoken(uptoken);
return obj;
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。