Skip to content

Commit a5d9595

Browse files
nitzanjtocker
authored andcommitted
Add url_suffix support for private images. (#76)
1 parent 04914ae commit a5d9595

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

cloudinary-core/src/main/java/com/cloudinary/Url.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,15 +449,19 @@ public String finalizeResourceType(String resourceType, String type, String urlS
449449
if (type == null) {
450450
type = "upload";
451451
}
452+
452453
if (!StringUtils.isBlank(urlSuffix)) {
453454
if (resourceType.equals("image") && type.equals("upload")) {
454455
resourceType = "images";
455456
type = null;
457+
} else if (resourceType.equals("image") && type.equals("private")) {
458+
resourceType = "private_images";
459+
type = null;
456460
} else if (resourceType.equals("raw") && type.equals("upload")) {
457461
resourceType = "files";
458462
type = null;
459463
} else {
460-
throw new IllegalArgumentException("URL Suffix only supported for image/upload and raw/upload");
464+
throw new IllegalArgumentException("URL Suffix only supported for image/upload, image/private and raw/upload");
461465
}
462466
}
463467
if (useRootPath) {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ public void testSupportUrlSuffixForRawUploads() {
228228
assertEquals("http://test123-res.cloudinary.com/files/test/hello", actual);
229229
}
230230

231+
@Test
232+
public void testSupportUrlSuffixForPrivateImages(){
233+
String actual = cloudinary.url().suffix("hello").privateCdn(true).resourceType("image").type("private").generate("test");
234+
assertEquals("http://test123-res.cloudinary.com/private_images/test/hello", actual);
235+
}
231236
@Test(expected = IllegalArgumentException.class)
232237
public void testDisllowUseRootPathInSharedDistribution() {
233238
cloudinary.url().useRootPath(true).generate("test");

0 commit comments

Comments
 (0)