gpt4 book ai didi

com.qiniu.common.Zone.zone0()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 11:24:40 26 4
gpt4 key购买 nike

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

Zone.zone0介绍

[英]华东机房相关域名
[中]华东机房相关域名

代码示例

代码示例来源:origin: nice-swa/my-site

public String upload(MultipartFile file, String fileName) {
  //构造一个带指定Zone对象的配置类
  Configuration cfg = new Configuration(Zone.zone0());
  //...其他参数参考类注释
  UploadManager uploadManager = new UploadManager(cfg);
  //默认不指定key的情况下,以文件内容的hash值作为文件名
  String key = null;
  Auth auth = Auth.create(ACCESS_KEY, SECRET_KEY);
  String upToken = auth.uploadToken(BUCKET);
  try {
    Response response = null;
    response = uploadManager.put(file.getInputStream(), fileName, upToken, null, null);
    //解析上传成功的结果
    DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);
    System.out.println(putRet.key);
    System.out.println(putRet.hash);
    return putRet.key;
  } catch (QiniuException ex) {
    Response r = ex.response;
    System.err.println(r.toString());
    try {
      System.err.println(r.bodyString());
    } catch (QiniuException ex2) {
      //ignore
    }
  } catch (IOException e) {
    e.printStackTrace();
  }
  return null;
}

代码示例来源:origin: Exrick/x-boot

/**
 * 构造一个带指定Zone对象的配置类 zone2华南
 */
public Configuration getConfiguration(){
  Configuration cfg = null;
  if(zone.equals(0)){
    cfg = new Configuration(Zone.zone0());
  }else if(zone.equals(1)){
    cfg = new Configuration(Zone.zone1());
  }else if(zone.equals(2)){
    cfg = new Configuration(Zone.zone2());
  }else if(zone.equals(3)){
    cfg = new Configuration(Zone.zoneNa0());
  }else if(zone.equals(4)){
    cfg = new Configuration(Zone.zoneAs0());
  }else {
    cfg = new Configuration(Zone.autoZone());
  }
  return cfg;
}

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

/**
 * 华东机房相关域名
 */
public static Zone huadong() {
  return zone0();
}

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

/**
 * 华东机房相关域名
 */
public static Zone huadong() {
  return zone0();
}

代码示例来源:origin: xkcoding/spring-boot-demo

/**
 * 华东机房
 */
@Bean
public com.qiniu.storage.Configuration qiniuConfig() {
  return new com.qiniu.storage.Configuration(Zone.zone0());
}

代码示例来源:origin: elunez/eladmin

/**
 * 得到机房的对应关系
 * @param zone
 * @return
 */
public static Configuration getConfiguration(String zone){
  if(HUAD.equals(zone)){
    return new Configuration(Zone.zone0());
  } else if(HUAB.equals(zone)){
    return new Configuration(Zone.zone1());
  } else if(HUAN.equals(zone)){
    return new Configuration(Zone.zone2());
  } else if (BEIM.equals(zone)){
    return new Configuration(Zone.zoneNa0());
    // 否则就是东南亚
  } else {
    return new Configuration(Zone.zoneAs0());
  }
}

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

@Test
public void testHello2() {
  Map<String, Zone> bucketKeyMap = new HashMap<String, Zone>();
  bucketKeyMap.put(TestConfig.testBucket_z0, Zone.zone0());
  bucketKeyMap.put(TestConfig.testBucket_na0, Zone.zoneNa0());
  for (Map.Entry<String, Zone> entry : bucketKeyMap.entrySet()) {
    String bucket = entry.getKey();
    Zone zone = entry.getValue();
    Configuration c = new Configuration(zone);
    c.useHttpsDomains = true;
    UploadManager uploadManager = new UploadManager(c);
    hello(uploadManager, bucket);
  }
}

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

public void testFormLargeSize2() {
  Map<String, Zone> bucketKeyMap = new HashMap<String, Zone>();
  bucketKeyMap.put(TestConfig.testBucket_z0, Zone.zone0());
  bucketKeyMap.put(TestConfig.testBucket_na0, Zone.zoneNa0());
  for (Map.Entry<String, Zone> entry : bucketKeyMap.entrySet()) {
    Configuration c = new Configuration(zone);
    c.putThreshold = 25 * 1024 * 1024;
    UploadManager uploadManager = new UploadManager(new Configuration(Zone.zone0()));

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

@Test
  public void testZ() {
    Zone z1 = new Zone.Builder(Zone.zone0()).upHttp("http://uphttp").build();
    Assert.assertSame(z1.getUpHttp(null), "http://uphttp");
    Assert.assertSame(Zone.zone0().getUpHttp(null), "http://up.qiniu.com");
  }
}

代码示例来源:origin: wuyouzhuguli/FEBS-Security

public static String upload(FileInputStream file, String fileName) {
  // 构造一个带指定Zone对象的配置类
  Configuration cfg = new Configuration(Zone.zone0());
  // 其他参数参考类注释
  UploadManager uploadManager = new UploadManager(cfg);
  try {
    Auth auth = Auth.create(properies.getOss().getQiniu().getAccessKey(), properies.getOss().getQiniu().getSecretKey());
    String upToken = auth.uploadToken(properies.getOss().getQiniu().getBucket());
    try {
      Response response = uploadManager.put(file, fileName, upToken, null, null);
      // 解析上传成功的结果
      DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);
      return properies.getOss().getQiniu().getPath() + "/" + putRet.key;
    } catch (QiniuException ex) {
      Response r = ex.response;
      logger.error(r.toString());
      try {
        logger.error(r.bodyString());
      } catch (QiniuException ignore) {
      }
    }
  } catch (Exception e) {
    logger.error("error", e);
  }
  return null;
}

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

public void testFormLargeSize() {
  Map<String, Zone> bucketKeyMap = new HashMap<String, Zone>();
  bucketKeyMap.put(TestConfig.testBucket_z0, Zone.zone0());
  bucketKeyMap.put(TestConfig.testBucket_na0, Zone.zoneNa0());
  for (Map.Entry<String, Zone> entry : bucketKeyMap.entrySet()) {
    String bucket = entry.getKey();
    Zone zone = entry.getValue();
    Configuration c = new Configuration(zone);
    c.putThreshold = 25 * 1024 * 1024;
    UploadManager uploadManager = new UploadManager(new Configuration(Zone.zone0()));
    final String expectKey = "yyyyyy";
    File f = null;
    try {
      f = TempFile.createFile(c.putThreshold / 1024 - 1);
    } catch (IOException e) {
      e.printStackTrace();
    }
    String token = TestConfig.testAuth.uploadToken(bucket, expectKey);
    Response r = null;
    try {
      r = uploadManager.put(f, expectKey, token, null, null, false);
    } catch (QiniuException e) {
      try {
        assertEquals("_", e.response.bodyString());
      } catch (QiniuException e1) {
        e1.printStackTrace();
      }
    }
  }
}

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

@Test
public void testAvthumb() {
  Map<String, Zone> cases = new HashMap<String, Zone>();
  cases.put(TestConfig.testBucket_z0, Zone.zone0());
  cases.put(TestConfig.testBucket_na0, Zone.zoneNa0());
  cases.put(TestConfig.testBucket_z0, Zone.autoZone());

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

public void setUp() throws UnknownHostException {
  IResolver[] resolvers = new IResolver[2];
  resolvers[0] = SystemDnsServer.defaultResolver();
  resolvers[1] = new Resolver(InetAddress.getByName("119.29.29.29"));
  final DnsClient dnsClient = new DnsClient(resolvers);
  config = new Configuration();
  config.zone = Zone.zone0();
  config.dns = new Dns() {
    @Override
    public List<InetAddress> lookup(String hostname) throws UnknownHostException {
      InetAddress[] ips;
      try {
        Domain domain = new Domain(hostname, true, true);
        ips = dnsClient.queryInetAddress(domain);
      } catch (IOException e) {
        e.printStackTrace();
        throw new UnknownHostException(e.getMessage());
      }
      if (ips == null) {
        throw new UnknownHostException(hostname + " resolve failed.");
      }
      List<InetAddress> l = new ArrayList<>(ips.length);
      Collections.addAll(l, ips);
      return l;
    }
  };
  uploadManager = new UploadManager(config);
}

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

private void template(int size, boolean https) throws IOException {
  Map<String, Zone> bucketZoneMap = new HashMap<String, Zone>();
  bucketZoneMap.put(TestConfig.testBucket_z0, Zone.zone0());
  bucketZoneMap.put(TestConfig.testBucket_na0, Zone.zoneNa0());

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

@Test
public void testXVar() throws IOException {
  Map<String, Zone> bucketZoneMap = new HashMap<String, Zone>();
  bucketZoneMap.put(TestConfig.testBucket_z0, Zone.zone0());
  bucketZoneMap.put(TestConfig.testBucket_na0, Zone.zoneNa0());

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

private void template(int size, boolean https) throws IOException {
  Map<String, Zone> bucketKeyMap = new HashMap<String, Zone>();
  bucketKeyMap.put(TestConfig.testBucket_z0, Zone.zone0());
  bucketKeyMap.put(TestConfig.testBucket_na0, Zone.zoneNa0());
  for (Map.Entry<String, Zone> entry : bucketKeyMap.entrySet()) {

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

bucketKeyMap.put(TestConfig.testBucket_z0, Zone.zone0());
bucketKeyMap.put(TestConfig.testBucket_na0, Zone.zoneNa0());
for (Map.Entry<String, Zone> entry : bucketKeyMap.entrySet()) {

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

private void template(final int size) throws IOException {
  Map<String, Zone> bucketKeyMap = new HashMap<String, Zone>();
  bucketKeyMap.put(TestConfig.testBucket_z0, Zone.zone0());
  bucketKeyMap.put(TestConfig.testBucket_na0, Zone.zoneNa0());
  for (Map.Entry<String, Zone> entry : bucketKeyMap.entrySet()) {

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com