本文整理了Java中com.cloudinary.Url.version()
方法的一些代码示例,展示了Url.version()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Url.version()
方法的具体详情如下:
包路径:com.cloudinary.Url
类名称:Url
方法名:version
暂无
代码示例来源:origin: com.cloudinary/cloudinary-core
version(version);
代码示例来源:origin: cloudinary/cloudinary_java
version(version);
代码示例来源:origin: cloudinary/cloudinary_java
@Test
public void testExplicit() throws IOException {
Map result = cloudinary.uploader().explicit("sample", asMap("eager", Collections.singletonList(new Transformation().crop("scale").width(2.0)), "type", "upload", "moderation", "manual"));
String url = cloudinary.url().transformation(new Transformation().crop("scale").width(2.0)).format("jpg").version(result.get("version")).generate("sample");
String eagerUrl = (String) ((Map) ((List) result.get("eager")).get(0)).get("url");
String cloudName = cloudinary.config.cloudName;
assertEquals(eagerUrl.substring(eagerUrl.indexOf(cloudName)), url.substring(url.indexOf(cloudName)));
}
代码示例来源:origin: cloudinary/cloudinary_java
@Test
public void testFolders() {
// should add version if public_id contains /
String result = cloudinary.url().generate("folder/test");
assertEquals(DEFAULT_UPLOAD_PATH + "v1/folder/test", result);
result = cloudinary.url().version(123).generate("folder/test");
assertEquals(DEFAULT_UPLOAD_PATH + "v123/folder/test", result);
}
代码示例来源:origin: cloudinary/cloudinary_java
@Test
public void testUrlInTag() {
String message = "should add token to an image tag url";
String url = cloudinary.url().signed(true).resourceType("image").type("authenticated").version("1486020273").imageTag("sample.jpg");
assertThat(url, Matchers.matchesPattern("<img.*src='http://res.cloudinary.com/test123/image/authenticated/v1486020273/sample.jpg\\?__cld_token__=st=11111111~exp=11111411~hmac=9bd6f41e2a5893da8343dc8eb648de8bf73771993a6d1457d49851250caf3b80.*>"));
}
}
代码示例来源:origin: cloudinary/cloudinary_android
@Test
public void testExplicit() throws Exception {
if (cloudinary.config.apiSecret == null)
return;
JSONObject result = new JSONObject(cloudinary.uploader().explicit("sample",
ObjectUtils.asMap("eager", Collections.singletonList(new Transformation().crop("scale").width(2.0)), "type", "upload")));
String url = cloudinary.url().transformation(new Transformation().crop("scale").width(2.0)).format("jpg")
.version(result.get("version")).generate("sample");
assertEquals(url, result.getJSONArray("eager").getJSONObject(0).get("url"));
}
代码示例来源:origin: cloudinary/cloudinary_java
@Test
public void testSignedUrl() {
// should correctly sign a url
String expected = DEFAULT_UPLOAD_PATH + "s--Ai4Znfl3--/c_crop,h_20,w_10/v1234/image.jpg";
String actual = cloudinary.url().version(1234).transformation(new Transformation().crop("crop").width(10).height(20)).signed(true)
.generate("image.jpg");
assertEquals(expected, actual);
expected = DEFAULT_UPLOAD_PATH + "s----SjmNDA--/v1234/image.jpg";
actual = cloudinary.url().version(1234).signed(true).generate("image.jpg");
assertEquals(expected, actual);
expected = DEFAULT_UPLOAD_PATH + "s--Ai4Znfl3--/c_crop,h_20,w_10/image.jpg";
actual = cloudinary.url().transformation(new Transformation().crop("crop").width(10).height(20)).signed(true).generate("image.jpg");
assertEquals(expected, actual);
}
代码示例来源:origin: cloudinary/cloudinary_java
@Test
public void testAuthenticatedUrl() {
cloudinary.config.privateCdn = true;
String message = "should add token if authToken is globally set and signed = true";
String url = cloudinary.url().signed(true).resourceType("image").type("authenticated").version("1486020273").generate("sample.jpg");
assertEquals(message,"http://test123-res.cloudinary.com/image/authenticated/v1486020273/sample.jpg?__cld_token__=st=11111111~exp=11111411~hmac=8db0d753ee7bbb9e2eaf8698ca3797436ba4c20e31f44527e43b6a6e995cfdb3", url);
message = "should add token for 'public' resource";
url = cloudinary.url().signed(true).resourceType("image").type("public").version("1486020273").generate("sample.jpg");
assertEquals(message,"http://test123-res.cloudinary.com/image/public/v1486020273/sample.jpg?__cld_token__=st=11111111~exp=11111411~hmac=c2b77d9f81be6d89b5d0ebc67b671557e88a40bcf03dd4a6997ff4b994ceb80e", url);
message = "should not add token if signed is false";
url = cloudinary.url().resourceType("image").type("authenticated").version("1486020273").generate("sample.jpg");
assertEquals(message,"http://test123-res.cloudinary.com/image/authenticated/v1486020273/sample.jpg", url);
message = "should not add token if authToken is globally set but null auth token is explicitly set and signed = true";
url = cloudinary.url().authToken(AuthToken.NULL_AUTH_TOKEN).signed(true).resourceType("image").type("authenticated").version("1486020273").generate("sample.jpg");
assertEquals(message,"http://test123-res.cloudinary.com/image/authenticated/s--v2fTPYTu--/v1486020273/sample.jpg", url);
message = "explicit authToken should override global setting";
url = cloudinary.url().signed(true).authToken(new AuthToken(ALT_KEY).startTime(222222222).duration(100)).resourceType("image").type("authenticated").transformation(new Transformation().crop("scale").width(300)).generate("sample.jpg");
assertEquals(message,"http://test123-res.cloudinary.com/image/authenticated/c_scale,w_300/sample.jpg?__cld_token__=st=222222222~exp=222222322~hmac=55cfe516530461213fe3b3606014533b1eca8ff60aeab79d1bb84c9322eebc1f", url);
message = "should compute expiration as start time + duration";
url = cloudinary.url().signed(true).authToken(new AuthToken().startTime(11111111).duration(300))
.type("authenticated").version("1486020273").generate("sample.jpg");
assertEquals(message,"http://test123-res.cloudinary.com/image/authenticated/v1486020273/sample.jpg?__cld_token__=st=11111111~exp=11111411~hmac=8db0d753ee7bbb9e2eaf8698ca3797436ba4c20e31f44527e43b6a6e995cfdb3", url);
}
内容来源于网络,如有侵权,请联系作者删除!