当前位置:   article > 正文

java上传相同的文件,当使用相同的KEY,上传文件问题

java上传重复文件会怎么样吗

这种方式 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;

}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Li_阴宅/article/detail/871601
推荐阅读
相关标签
  

闽ICP备14008679号