Skip to content

Commit 5c64a5d

Browse files
nitzanjtocker
authored andcommitted
Add support for fetch overlay/underlay (#69)
1 parent e10f455 commit 5c64a5d

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.cloudinary.transformation;
2+
3+
import com.cloudinary.utils.Base64Coder;
4+
5+
public class FetchLayer extends AbstractLayer<FetchLayer> {
6+
7+
public FetchLayer() {
8+
this.type = "fetch";
9+
}
10+
11+
public FetchLayer url(String remoteUrl) {
12+
this.publicId = Base64Coder.encodeString(remoteUrl);
13+
return this;
14+
}
15+
16+
@Override
17+
public FetchLayer type(String type) {
18+
throw new UnsupportedOperationException("Cannot modify type for fetch layers");
19+
}
20+
21+
@Override
22+
FetchLayer getThis() {
23+
return this;
24+
}
25+
}

cloudinary-core/src/test/java/com/cloudinary/test/CloudinaryTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,11 @@ public void testOverlayOptions() {
988988
"text:Arial_18_bold_italic_letter_spacing_4_line_spacing_3:Hello%20World%252C%20Nice%20to%20meet%20you%3F",
989989
new SubtitlesLayer().publicId("sample_sub_en.srt"), "subtitles:sample_sub_en.srt",
990990
new SubtitlesLayer().publicId("sample_sub_he.srt").fontFamily("Arial").fontSize(40),
991-
"subtitles:Arial_40:sample_sub_he.srt"};
991+
"subtitles:Arial_40:sample_sub_he.srt",
992+
new FetchLayer().url("https://test").resourceType("image"),
993+
"fetch:aHR0cHM6Ly90ZXN0",
994+
new FetchLayer().url("https://test"),
995+
"fetch:aHR0cHM6Ly90ZXN0"};
992996

993997
for (int i = 0; i < tests.length; i += 2) {
994998
Object layer = tests[i];

0 commit comments

Comments
 (0)