com.qiniu.http.Response.jsonToObject()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(142)

本文整理了Java中com.qiniu.http.Response.jsonToObject方法的一些代码示例,展示了Response.jsonToObject的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.jsonToObject方法的具体详情如下:
包路径:com.qiniu.http.Response
类名称:Response
方法名:jsonToObject

Response.jsonToObject介绍

暂无

代码示例

代码示例来源:origin: qiniu/java-sdk

/**
 * 通过 API 接口查询上传域名
 */
private UCRet getZoneJson(ZoneIndex index) throws QiniuException {
  String address = ucServer + "/v1/query?ak=" + index.accessKey + "&bucket=" + index.bucket;
  Response r = client.get(address);
  return r.jsonToObject(UCRet.class);
}

代码示例来源:origin: com.qiniu/qiniu-java-sdk

/**
 * 通过 API 接口查询上传域名
 */
private UCRet getZoneJson(ZoneIndex index) throws QiniuException {
  String address = ucServer + "/v1/query?ak=" + index.accessKey + "&bucket=" + index.bucket;
  Response r = client.get(address);
  return r.jsonToObject(UCRet.class);
}

代码示例来源:origin: qiniu/java-sdk

private <T> T post(String path, String body, Class<T> classOfT) throws QiniuException {
  String url = apiServer + "/v2/hubs/" + hub + "/streams" + path;
  byte[] b = body.getBytes();
  StringMap headers = auth.authorizationV2(url, "POST", b, Client.JsonMime);
  Response r = client.post(url, b, headers, Client.JsonMime);
  if (classOfT != null) {
    return r.jsonToObject(classOfT);
  }
  return null;
}

代码示例来源:origin: com.qiniu/qiniu-java-sdk

private <T> T post(String path, String body, Class<T> classOfT) throws QiniuException {
  String url = apiServer + "/v2/hubs/" + hub + "/streams" + path;
  byte[] b = body.getBytes();
  StringMap headers = auth.authorizationV2(url, "POST", b, Client.JsonMime);
  Response r = client.post(url, b, headers, Client.JsonMime);
  if (classOfT != null) {
    return r.jsonToObject(classOfT);
  }
  return null;
}

代码示例来源:origin: qiniu/java-sdk

private <T> T get(String path, Class<T> classOfT) throws QiniuException {
  String url = apiServer + "/v2/hubs/" + hub + "/streams" + path;
  StringMap headers = auth.authorizationV2(url);
  Response r = client.get(url, headers);
  if (classOfT != null) {
    return r.jsonToObject(classOfT);
  }
  return null;
}

代码示例来源:origin: com.qiniu/qiniu-java-sdk

private <T> T get(String path, Class<T> classOfT) throws QiniuException {
  String url = apiServer + "/v2/hubs/" + hub + "/streams" + path;
  StringMap headers = auth.authorizationV2(url);
  Response r = client.get(url, headers);
  if (classOfT != null) {
    return r.jsonToObject(classOfT);
  }
  return null;
}

代码示例来源:origin: qiniu/java-sdk

public String error() {
    if (error != null) {
      return error;
    }
    if (response == null || response.statusCode / 100 == 2 || !response.isJson()) {
      return null;
    }
    Error e = null;
    try {
      e = response.jsonToObject(Error.class);
    } catch (QiniuException e1) {
      e1.printStackTrace();
    }
    error = e == null ? "" : e.error;
    return error;
  }
}

代码示例来源:origin: qiniu/java-sdk

/**
 * 获取CDN域名访问日志的下载链接,具体下载操作请自行根据链接下载
 * 参考文档:<a href="http://developer.qiniu.com/fusion/api/download-the-log">日志下载</a>
 *
 * @param domains 待获取日志下载信息的域名列表
 * @param logDate 待获取日志的具体日期,格式为:2017-02-18
 * @return 获取日志下载链接的回复
 */
public CdnResult.LogListResult getCdnLogList(String[] domains, String logDate) throws QiniuException {
  HashMap<String, String> req = new HashMap<>();
  req.put("domains", StringUtils.join(domains, ";"));
  req.put("day", logDate);
  byte[] body = Json.encode(req).getBytes(Constants.UTF_8);
  String url = server + "/v2/tune/log/list";
  StringMap headers = auth.authorizationV2(url, "POST", body, Client.JsonMime);
  Response response = client.post(url, body, headers, Client.JsonMime);
  return response.jsonToObject(CdnResult.LogListResult.class);
}

代码示例来源:origin: com.qiniu/qiniu-java-sdk

public String error() {
    if (error != null) {
      return error;
    }
    if (response == null || response.statusCode / 100 == 2 || !response.isJson()) {
      return null;
    }
    Error e = null;
    try {
      e = response.jsonToObject(Error.class);
    } catch (QiniuException e1) {
      e1.printStackTrace();
    }
    error = e == null ? "" : e.error;
    return error;
  }
}

代码示例来源:origin: com.qiniu/qiniu-java-sdk

/**
 * 获取CDN域名访问日志的下载链接,具体下载操作请自行根据链接下载
 * 参考文档:<a href="http://developer.qiniu.com/fusion/api/download-the-log">日志下载</a>
 *
 * @param domains 待获取日志下载信息的域名列表
 * @param logDate 待获取日志的具体日期,格式为:2017-02-18
 * @return 获取日志下载链接的回复
 */
public CdnResult.LogListResult getCdnLogList(String[] domains, String logDate) throws QiniuException {
  HashMap<String, String> req = new HashMap<>();
  req.put("domains", StringUtils.join(domains, ";"));
  req.put("day", logDate);
  byte[] body = Json.encode(req).getBytes(Constants.UTF_8);
  String url = server + "/v2/tune/log/list";
  StringMap headers = auth.authorizationV2(url, "POST", body, Client.JsonMime);
  Response response = client.post(url, body, headers, Client.JsonMime);
  return response.jsonToObject(CdnResult.LogListResult.class);
}

代码示例来源:origin: qiniu/java-sdk

public BucketInfo getBucketInfo(String bucket) throws QiniuException {
  String url = String.format("%s/v2/bucketInfo?bucket=%s", configuration.ucHost(), bucket);
  Response res = post(url, null);
  if (!res.isOK()) {
    throw new QiniuException(res);
  }
  BucketInfo info = res.jsonToObject(BucketInfo.class);
  res.close();
  return info;
}

代码示例来源:origin: com.qiniu/qiniu-java-sdk

public BucketInfo getBucketInfo(String bucket) throws QiniuException {
  String url = String.format("%s/v2/bucketInfo?bucket=%s", configuration.ucHost(), bucket);
  Response res = post(url, null);
  if (!res.isOK()) {
    throw new QiniuException(res);
  }
  BucketInfo info = res.jsonToObject(BucketInfo.class);
  res.close();
  return info;
}

代码示例来源:origin: qiniu/java-sdk

public FileListing listFiles(String bucket, String prefix, String marker, int limit, String delimiter)
    throws QiniuException {
  Response response = listV1(bucket, prefix, marker, limit, delimiter);
  if (!response.isOK()) {
    throw new QiniuException(response);
  }
  FileListing fileListing = response.jsonToObject(FileListing.class);
  response.close();
  return fileListing;
}

代码示例来源:origin: com.qiniu/qiniu-java-sdk

public FileListing listFiles(String bucket, String prefix, String marker, int limit, String delimiter)
    throws QiniuException {
  Response response = listV1(bucket, prefix, marker, limit, delimiter);
  if (!response.isOK()) {
    throw new QiniuException(response);
  }
  FileListing fileListing = response.jsonToObject(FileListing.class);
  response.close();
  return fileListing;
}

代码示例来源:origin: qiniu/java-sdk

/**
 * 获取该空间下所有的domain
 *
 * @param bucket
 * @return 该空间名下的domain
 * @throws QiniuException
 */
public String[] domainList(String bucket) throws QiniuException {
  String url = String.format("%s/v6/domain/list?tbl=%s", configuration.apiHost(), bucket);
  Response res = get(url);
  if (!res.isOK()) {
    throw new QiniuException(res);
  }
  String[] domains = res.jsonToObject(String[].class);
  res.close();
  return domains;
}

代码示例来源:origin: qiniu/java-sdk

/**
 * 获取账号下所有空间名称列表
 *
 * @return 空间名称列表
 */
public String[] buckets() throws QiniuException {
  // 获取 bucket 列表 写死用rs.qiniu.com or rs.qbox.me @冯立元
  String url = String.format("%s/buckets", configuration.rsHost());
  Response res = get(url);
  if (!res.isOK()) {
    throw new QiniuException(res);
  }
  String[] buckets = res.jsonToObject(String[].class);
  res.close();
  return buckets;
}

代码示例来源:origin: com.qiniu/qiniu-java-sdk

/**
 * 获取账号下所有空间名称列表
 *
 * @return 空间名称列表
 */
public String[] buckets() throws QiniuException {
  // 获取 bucket 列表 写死用rs.qiniu.com or rs.qbox.me @冯立元
  String url = String.format("%s/buckets", configuration.rsHost());
  Response res = get(url);
  if (!res.isOK()) {
    throw new QiniuException(res);
  }
  String[] buckets = res.jsonToObject(String[].class);
  res.close();
  return buckets;
}

代码示例来源:origin: qiniu/java-sdk

/**
 * 获取空间中文件的属性
 *
 * @param bucket  空间名称
 * @param fileKey 文件名称
 * @return 文件属性
 * @throws QiniuException
 * @link http://developer.qiniu.com/kodo/api/stat
 */
public FileInfo stat(String bucket, String fileKey) throws QiniuException {
  Response res = rsGet(bucket, String.format("/stat/%s", encodedEntry(bucket, fileKey)));
  if (!res.isOK()) {
    throw new QiniuException(res);
  }
  FileInfo fileInfo = res.jsonToObject(FileInfo.class);
  res.close();
  return fileInfo;
}

代码示例来源:origin: com.qiniu/qiniu-java-sdk

/**
 * 获取该空间下所有的domain
 *
 * @param bucket
 * @return 该空间名下的domain
 * @throws QiniuException
 */
public String[] domainList(String bucket) throws QiniuException {
  String url = String.format("%s/v6/domain/list?tbl=%s", configuration.apiHost(), bucket);
  Response res = get(url);
  if (!res.isOK()) {
    throw new QiniuException(res);
  }
  String[] domains = res.jsonToObject(String[].class);
  res.close();
  return domains;
}

代码示例来源:origin: vakinge/jeesuite-libs

/**
 * 处理上传结果,返回文件url
 * 
 * @return
 * @throws QiniuException
 */
private String processUploadResponse(Response res) throws QiniuException {
  if (res.isOK()) {
    UploadResult ret = res.jsonToObject(UploadResult.class);
    return getFullPath(ret.key);
  }
  throw new FSOperErrorException(name(), res.toString());
}

相关文章