/** * 构造一个带指定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; }
public String upHost(String upToken) throws QiniuException { ZoneReqInfo zoneReqInfo = new ZoneReqInfo(upToken); if (zone == null) { zone = Zone.autoZone(); } return useHttpsDomains ? zone.getUpHttps(zoneReqInfo) : zone.getUpHttp(zoneReqInfo); }
public String upHostBackup(String upToken) throws QiniuException { ZoneReqInfo zoneReqInfo = new ZoneReqInfo(upToken); if (zone == null) { zone = Zone.autoZone(); } return useHttpsDomains ? zone.getUpBackupHttps(zoneReqInfo) : zone.getUpBackupHttp(zoneReqInfo); }
@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); } }
public QiniuProvider(String urlprefix, String bucketName, String accessKey, String secretKey,boolean isPrivate) { Validate.notBlank(bucketName, "[bucketName] not defined"); Validate.notBlank(accessKey, "[accessKey] not defined"); Validate.notBlank(secretKey, "[secretKey] not defined"); Validate.notBlank(urlprefix, "[urlprefix] not defined"); this.urlprefix = urlprefix.endsWith(DIR_SPLITER) ? urlprefix : urlprefix + DIR_SPLITER; this.bucketName = bucketName; auth = Auth.create(accessKey, secretKey); Zone z = Zone.autoZone(); Configuration c = new Configuration(z); uploadManager = new UploadManager(c); bucketManager = new BucketManager(auth,c); this.isPrivate = isPrivate; this.host = StringUtils.remove(urlprefix,"/").split(":")[1]; }
@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()); cases.put(TestConfig.testBucket_na0, Zone.autoZone());
public String rsHost(String ak, String bucket) { ZoneReqInfo zoneReqInfo = new ZoneReqInfo(ak, bucket); if (zone == null) { zone = Zone.autoZone(); } return useHttpsDomains ? zone.getRsHttps(zoneReqInfo) : zone.getRsHttp(zoneReqInfo); }
public String ioHost(String ak, String bucket) { ZoneReqInfo zoneReqInfo = new ZoneReqInfo(ak, bucket); if (zone == null) { zone = Zone.autoZone(); } return useHttpsDomains ? zone.getIovipHttps(zoneReqInfo) : zone.getIovipHttp(zoneReqInfo); }
public String rsfHost(String ak, String bucket) { ZoneReqInfo zoneReqInfo = new ZoneReqInfo(ak, bucket); if (zone == null) { zone = Zone.autoZone(); } return useHttpsDomains ? zone.getRsfHttps(zoneReqInfo) : zone.getRsfHttp(zoneReqInfo); }
public String apiHost(String ak, String bucket) { ZoneReqInfo zoneReqInfo = new ZoneReqInfo(ak, bucket); if (zone == null) { zone = Zone.autoZone(); } return useHttpsDomains ? zone.getApiHttps(zoneReqInfo) : zone.getApiHttp(zoneReqInfo); }
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; }
/** * 北美机房相关域名 */ public static Zone beimei() { return zoneNa0(); }
/** * 华北机房相关域名 */ public static Zone huabei() { return zone1(); }
/** * 华南机房相关域名 */ public static Zone huanan() { return zone2(); }
/** * 新加坡机房相关域名 */ public static Zone xinjiapo() { return zoneAs0(); }
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()) { String bucket = entry.getKey(); Configuration c = new Configuration(zone); c.putThreshold = 25 * 1024 * 1024; UploadManager uploadManager = new UploadManager(new Configuration(Zone.zone0()));
zone == null ? Zone.autoZone() : zone);
public String upHostBackup(String upToken) throws QiniuException { ZoneReqInfo zoneReqInfo = new ZoneReqInfo(upToken); if (zone == null) { zone = Zone.autoZone(); } return useHttpsDomains ? zone.getUpBackupHttps(zoneReqInfo) : zone.getUpBackupHttp(zoneReqInfo); }
public String rsHost(String ak, String bucket) { ZoneReqInfo zoneReqInfo = new ZoneReqInfo(ak, bucket); if (zone == null) { zone = Zone.autoZone(); } return useHttpsDomains ? zone.getRsHttps(zoneReqInfo) : zone.getRsHttp(zoneReqInfo); }