本文整理汇总了Java中com.qcloud.cos.meta.InsertOnly类的典型用法代码示例。如果您正苦于以下问题:Java InsertOnly类的具体用法?Java InsertOnly怎么用?Java InsertOnly使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InsertOnly类属于com.qcloud.cos.meta包,在下文中一共展示了InsertOnly类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: upload
import com.qcloud.cos.meta.InsertOnly; //导入依赖的package包/类
public JSONObject upload(String fileCosPath, byte[] bytes) {
if (client == null) {
init();
}
if (!fileCosPath.startsWith("/")) {
fileCosPath = "/"+ fileCosPath;
}
if (root != null) {
fileCosPath = root + fileCosPath;
}
UploadFileRequest request = new UploadFileRequest(bucket, fileCosPath, bytes);
request.setInsertOnly(InsertOnly.OVER_WRITE);
request.setEnableShaDigest(true);
String result = client.uploadFile(request);
JSONObject cosResult = JSON.parseObject(result);
String msg = (String)cosResult.remove("message");
cosResult.put("msg", msg);
return cosResult;
}
示例2: uploadSliceFile
import com.qcloud.cos.meta.InsertOnly; //导入依赖的package包/类
/**
* 分片上传文件
*
* @param request 分片上传请求
* @return 服务器端返回的操作结果,成员code为0表示成功,具体参照文档手册
* @throws Exception
*/
public String uploadSliceFile(UploadSliceFileRequest request) throws AbstractCosException {
request.check_param();
UploadSliceFileContext context = new UploadSliceFileContext(request);
context.setUrl(buildUrl(request));
String retStr = uploadFileWithCheckPoint(context);
if (request.getInsertOnly() != InsertOnly.OVER_WRITE) {
return retStr;
}
// 对于Overwrite类型,覆盖上传失败,做特殊处理,删掉重新传
JSONObject retJson = new JSONObject(retStr);
if (retJson.getInt("code") == 0) {
return retStr;
}
// 1. Delete
DelFileRequest del_request =
new DelFileRequest(request.getBucketName(), request.getCosPath());
String delRet = delFile(del_request);
JSONObject delJson = new JSONObject(delRet);
if (delJson.getInt("code") != 0) {
return retStr;
}
// 2. Upload Again
retStr = uploadFileWithCheckPoint(context);
retJson = new JSONObject(retStr);
if (retJson.getInt("code") != 0) {
del_request = new DelFileRequest(request.getBucketName(), request.getCosPath());
delFile(del_request);
}
return retStr;
}
示例3: getInsertOnly
import com.qcloud.cos.meta.InsertOnly; //导入依赖的package包/类
public InsertOnly getInsertOnly() {
return insertOnly;
}
示例4: setInsertOnly
import com.qcloud.cos.meta.InsertOnly; //导入依赖的package包/类
public void setInsertOnly(InsertOnly insertOnly) {
this.insertOnly = insertOnly;
}
示例5: getInsertOnly
import com.qcloud.cos.meta.InsertOnly; //导入依赖的package包/类
public InsertOnly getInsertOnly() {
return insertOnly;
}
示例6: setInsertOnly
import com.qcloud.cos.meta.InsertOnly; //导入依赖的package包/类
public void setInsertOnly(InsertOnly insertOnly) {
this.insertOnly = insertOnly;
}