Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cloudinary-core/src/main/java/com/cloudinary/Api.java
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ private ApiResponse publishResource(String byKey, Object value, Map options) thr
uri.add("publish_resources");
Map params = new HashMap<String, Object>();
params.put(byKey, value);
params.putAll(ObjectUtils.only(options, "invalidate", "overwrite"));
params.putAll(ObjectUtils.only(options, "invalidate", "overwrite", "type"));
return callApi(HttpMethod.POST, uri, params, options);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,35 @@ public void testPublishByIds() throws Exception {
cloudinary.uploader().destroy(publicId, null);
}

@Test
public void testPublishWithType() throws Exception {
Map response = cloudinary.uploader().upload(SRC_TEST_IMAGE, ObjectUtils.asMap("tags", uniqueTag, "type", "authenticated"));
String publicId = (String) response.get("public_id");

// publish with wrong type - verify publish fails
response = cloudinary.api().publishByIds(Arrays.asList(publicId), ObjectUtils.asMap("type", "private"));
List published = (List) response.get("published");
List failed = (List) response.get("failed");
assertNotNull(published);
assertNotNull(failed);
assertEquals(published.size(), 0);
assertEquals(failed.size(), 1);

// publish with correct type - verify publish succeeds
response = cloudinary.api().publishByIds(Arrays.asList(publicId), ObjectUtils.asMap("type", "authenticated"));
published = (List) response.get("published");
failed = (List) response.get("failed");
assertNotNull(published);
assertNotNull(failed);
assertEquals(published.size(), 1);
assertEquals(failed.size(), 0);

Map resource = (Map) published.get(0);
assertEquals(resource.get("public_id"), publicId);
assertNotNull(resource.get("url"));
cloudinary.uploader().destroy(publicId, null);
}

@Test
public void testPublishByPrefix() throws Exception {
Map response = cloudinary.uploader().upload(SRC_TEST_IMAGE, ObjectUtils.asMap("tags", uniqueTag, "type", "authenticated"));
Expand Down