本文整理了Java中com.cloudinary.Url.resourceType()
方法的一些代码示例,展示了Url.resourceType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Url.resourceType()
方法的具体详情如下:
包路径:com.cloudinary.Url
类名称:Url
方法名:resourceType
暂无
代码示例来源:origin: com.cloudinary/cloudinary-core
public Url resourcType(String resourceType) {
return resourceType(resourceType);
}
代码示例来源:origin: cloudinary/cloudinary_java
public Url resourcType(String resourceType) {
return resourceType(resourceType);
}
代码示例来源:origin: com.cloudinary/cloudinary
@Deprecated
public Url resourcType(String resourceType) {
return resourceType(resourceType);
}
代码示例来源:origin: cloudinary/cloudinary_android
private void loadVideo(final EffectData data) {
progressBar.setVisibility(View.VISIBLE);
imageView.setVisibility(View.GONE);
final DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, "Cloudinary Sample App"), null);
final ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
Url baseUrl = MediaManager.get().url().resourceType("video").publicId(data.getPublicId()).transformation(data.getTransformation());
MediaManager.get().responsiveUrl(exoPlayerView, baseUrl, FIT, new ResponsiveUrl.Callback() {
@Override
public void onUrlReady(Url url) {
String urlString = url.generate();
currentUrl = urlString;
MediaSource videoSource = new ExtractorMediaSource(Uri.parse(urlString), dataSourceFactory, extractorsFactory, null, null);
exoPlayer.addListener(listener);
exoPlayer.prepare(videoSource);
}
});
}
代码示例来源:origin: cloudinary/cloudinary_java
@Test(expected = IllegalArgumentException.class)
public void testDisllowUseRootPathIfNotImageUploadForRaw() {
cloudinary.url().useRootPath(true).privateCdn(true).resourceType("raw").generate("test");
}
代码示例来源:origin: cloudinary/cloudinary_android
public static String getCroppedThumbnailUrl(int size, Resource resource) {
return MediaManager.get().getCloudinary().url()
.resourceType(resource.getResourceType())
.transformation(new Transformation().gravity("auto").width(size).height(size))
.format("webp")
.generate(resource.getCloudinaryPublicId());
}
代码示例来源:origin: cloudinary/cloudinary_java
@Test
public void testSupportUrlSuffixForVideoUploads() {
String actual = cloudinary.url().suffix("hello").privateCdn(true).resourceType("video").generate("test");
assertEquals("http://test123-res.cloudinary.com/videos/test/hello", actual);
}
代码示例来源:origin: cloudinary/cloudinary_java
@Test
public void testSupportUrlSuffixForRawUploads() {
String actual = cloudinary.url().suffix("hello").privateCdn(true).resourceType("raw").generate("test");
assertEquals("http://test123-res.cloudinary.com/files/test/hello", actual);
}
代码示例来源:origin: cloudinary/cloudinary_java
@Test
public void testAudioFrequency() {
// should support an integer value
String actual = cloudinary.url().resourceType("video")
.transformation(new Transformation().audioFrequency(44100)).generate("video_id");
assertEquals(VIDEO_UPLOAD_PATH + "af_44100/video_id", actual);
// should support a string value
actual = cloudinary.url().resourceType("video").transformation(new Transformation().audioFrequency("44100"))
.generate("video_id");
assertEquals(VIDEO_UPLOAD_PATH + "af_44100/video_id", actual);
}
代码示例来源:origin: cloudinary/cloudinary_java
@Test
public void testDuration() {
String actual = cloudinary.url().resourceType("video").transformation(new Transformation().duration(2.63))
.generate("video_id");
assertEquals(VIDEO_UPLOAD_PATH + "du_2.63/video_id", actual);
actual = cloudinary.url().resourceType("video").transformation(new Transformation().duration("2.63p"))
.generate("video_id");
assertEquals(VIDEO_UPLOAD_PATH + "du_2.63p/video_id", actual);
actual = cloudinary.url().resourceType("video").transformation(new Transformation().duration("2.63%"))
.generate("video_id");
assertEquals(VIDEO_UPLOAD_PATH + "du_2.63p/video_id", actual);
actual = cloudinary.url().resourceType("video").transformation(new Transformation().durationPercent(2.63))
.generate("video_id");
assertEquals(VIDEO_UPLOAD_PATH + "du_2.63p/video_id", actual);
}
代码示例来源:origin: cloudinary/cloudinary_java
@Test
public void testZoom() {
String actual = cloudinary.url().resourceType("video").transformation(new Transformation().zoom("1.5"))
.generate("video_id");
assertEquals(VIDEO_UPLOAD_PATH + "z_1.5/video_id", actual);
actual = cloudinary.url().resourceType("video").transformation(new Transformation().zoom(1.5))
.generate("video_id");
assertEquals(VIDEO_UPLOAD_PATH + "z_1.5/video_id", actual);
}
代码示例来源:origin: cloudinary/cloudinary_java
@Test
public void testBitRate() {
// should support a numeric value
String actual = cloudinary.url().resourceType("video").transformation(new Transformation().bitRate(2048))
.generate("video_id");
assertEquals(VIDEO_UPLOAD_PATH + "br_2048/video_id", actual);
// should support a string value
actual = cloudinary.url().resourceType("video").transformation(new Transformation().bitRate("44k"))
.generate("video_id");
assertEquals(VIDEO_UPLOAD_PATH + "br_44k/video_id", actual);
actual = cloudinary.url().resourceType("video").transformation(new Transformation().bitRate("1m"))
.generate("video_id");
assertEquals(VIDEO_UPLOAD_PATH + "br_1m/video_id", actual);
}
代码示例来源:origin: cloudinary/cloudinary_java
@Test
public void testSupportUrlSuffixForPrivateImages() {
String actual = cloudinary.url().suffix("hello").privateCdn(true).resourceType("image").type("private").generate("test");
assertEquals("http://test123-res.cloudinary.com/private_images/test/hello", actual);
}
代码示例来源:origin: cloudinary/cloudinary_java
@Test
public void testAudioCodec() {
// should support a string value
String actual = cloudinary.url().resourceType("video").transformation(new Transformation().audioCodec("acc")).generate("video_id");
assertEquals(VIDEO_UPLOAD_PATH + "ac_acc/video_id", actual);
}
代码示例来源:origin: cloudinary/cloudinary_java
@Test
public void testSupportUrlSuffixForAuthenticatedImages() {
String actual = cloudinary.url().suffix("hello").privateCdn(true).resourceType("image").type("authenticated").generate("test");
assertEquals("http://test123-res.cloudinary.com/authenticated_images/test/hello", actual);
}
代码示例来源:origin: cloudinary/cloudinary_java
@Test
public void testVideoSampling() {
String actual = cloudinary.url().resourceType("video")
.transformation(new Transformation().videoSamplingFrames(20)).generate("video_id");
assertEquals(VIDEO_UPLOAD_PATH + "vs_20/video_id", actual);
actual = cloudinary.url().resourceType("video").transformation(new Transformation().videoSamplingSeconds(20))
.generate("video_id");
assertEquals(VIDEO_UPLOAD_PATH + "vs_20s/video_id", actual);
actual = cloudinary.url().resourceType("video").transformation(new Transformation().videoSamplingSeconds(20.0))
.generate("video_id");
assertEquals(VIDEO_UPLOAD_PATH + "vs_20.0s/video_id", actual);
actual = cloudinary.url().resourceType("video").transformation(new Transformation().videoSampling("2.3s"))
.generate("video_id");
assertEquals(VIDEO_UPLOAD_PATH + "vs_2.3s/video_id", actual);
}
代码示例来源:origin: cloudinary/cloudinary_java
@Test
public void testVideoCodec() {
// should support a string value
String actual = cloudinary.url().resourceType("video").transformation(new Transformation().videoCodec("auto"))
.generate("video_id");
assertEquals(VIDEO_UPLOAD_PATH + "vc_auto/video_id", actual);
// should support a hash value
actual = cloudinary.url().resourceType("video")
.transformation(
new Transformation().videoCodec(asMap("codec", "h264", "profile", "basic", "level", "3.1"))
).generate("video_id");
assertEquals(VIDEO_UPLOAD_PATH + "vc_h264:basic:3.1/video_id", actual);
}
代码示例来源: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_java
@Test
public void testStartOffset() {
String actual = cloudinary.url().resourceType("video").transformation(new Transformation().startOffset(2.63))
.generate("video_id");
assertEquals(VIDEO_UPLOAD_PATH + "so_2.63/video_id", actual);
actual = cloudinary.url().resourceType("video").transformation(new Transformation().startOffset("2.63p"))
.generate("video_id");
assertEquals(VIDEO_UPLOAD_PATH + "so_2.63p/video_id", actual);
actual = cloudinary.url().resourceType("video").transformation(new Transformation().startOffset("2.63%"))
.generate("video_id");
assertEquals(VIDEO_UPLOAD_PATH + "so_2.63p/video_id", actual);
actual = cloudinary.url().resourceType("video").transformation(new Transformation().startOffsetPercent(2.63))
.generate("video_id");
assertEquals(VIDEO_UPLOAD_PATH + "so_2.63p/video_id", actual);
actual = cloudinary.url().resourceType("video").transformation(new Transformation().startOffset("auto"))
.generate("video_id");
assertEquals(VIDEO_UPLOAD_PATH + "so_auto/video_id", 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);
}
内容来源于网络,如有侵权,请联系作者删除!