Skip to content

Commit a231072

Browse files
aditimadan-Cloudinarynitzanj
authored andcommitted
Allow generating archive with multiple resource types (#174)
1 parent 659249e commit a231072

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class ArchiveParams {
2626
private String[] targetTags = null;
2727
private String[] tags = null;
2828
private String[] publicIds = null;
29+
private String[] fullyQualifiedPublicIds = null;
2930
private String[] prefixes = null;
3031
private Transformation[] transformations = null;
3132
private Long expiresAt = null;
@@ -176,6 +177,15 @@ public ArchiveParams publicIds(String[] publicIds) {
176177
return this;
177178
}
178179

180+
public String[] fully_qualified_public_ids() {
181+
return fullyQualifiedPublicIds;
182+
}
183+
184+
public ArchiveParams fullyQualifiedPublicIds(String[] fullyQualifiedPublicIds) {
185+
this.fullyQualifiedPublicIds = fullyQualifiedPublicIds;
186+
return this;
187+
}
188+
179189
public String[] prefixes() {
180190
return prefixes;
181191
}
@@ -225,6 +235,9 @@ public Map<String, Object> toMap() {
225235
params.put("tags", tags);
226236
if (publicIds != null)
227237
params.put("public_ids", publicIds);
238+
if(fullyQualifiedPublicIds !=null){
239+
params.put("fully_qualified_public_ids", fullyQualifiedPublicIds);
240+
}
228241
if (prefixes != null)
229242
params.put("prefixes", prefixes);
230243
if (transformations != null) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ public static final Map<String, Object> buildArchiveParams(Map options, String t
179179
putArray("target_tags", options, params);
180180
putArray("tags", options, params);
181181
putArray("public_ids", options, params);
182+
putArray("fully_qualified_public_ids", options, params);
182183
putArray("prefixes", options, params);
183184
putEager("transformations", options, params);
184185
putObject("timestamp", options, params, Util.timestamp());

cloudinary-test-common/src/main/java/com/cloudinary/test/AbstractUploaderTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ abstract public class AbstractUploaderTest extends MockableTest {
3131
public static final int SRC_TEST_IMAGE_W = 241;
3232
public static final int SRC_TEST_IMAGE_H = 51;
3333
private static Map<String, Set<String>> toDelete = new HashMap<String, Set<String>>();
34+
public static final String SRC_FULLY_QUALIFIED_IMAGE="image/upload/sample";
35+
public static final String SRC_FULLY_QUALIFIED_VIDEO="video/upload/dog";
3436

3537
@BeforeClass
3638
public static void setUpClass() throws IOException {
@@ -40,6 +42,7 @@ public static void setUpClass() throws IOException {
4042
}
4143

4244
cloudinary.uploader().upload(SRC_TEST_IMAGE, asMap("tags", new String[]{SDK_TEST_TAG, UPLOADER_TAG, ARCHIVE_TAG}));
45+
cloudinary.uploader().upload(SRC_TEST_VIDEO, asMap("tags", new String[]{SDK_TEST_TAG, UPLOADER_TAG, ARCHIVE_TAG}, "public_id", "dog", "resource_type", "video"));
4346
cloudinary.uploader().upload(SRC_TEST_IMAGE, asMap("tags", new String[]{SDK_TEST_TAG, UPLOADER_TAG, ARCHIVE_TAG}, "resource_type", "raw"));
4447
cloudinary.uploader().upload(SRC_TEST_IMAGE,
4548
asMap("tags", new String[]{SDK_TEST_TAG, UPLOADER_TAG, ARCHIVE_TAG},
@@ -593,6 +596,13 @@ public void testCreateArchiveRaw() throws Exception {
593596

594597
}
595598

599+
@Test
600+
public void testCreateZipMultipleResourceTypes() throws Exception {
601+
Map result = cloudinary.uploader().createZip(ObjectUtils.asMap("fully_qualified_public_ids",(new String[]{SRC_FULLY_QUALIFIED_IMAGE,SRC_FULLY_QUALIFIED_VIDEO}),"resource_type","auto"));
602+
assertEquals(2, result.get("file_count"));
603+
cloudinary.api().deleteResources(Arrays.asList(result.get("public_id").toString()), asMap("resource_type", "raw"));
604+
}
605+
596606
@Test
597607
public void testDownloadArchive() throws Exception {
598608
String result = cloudinary.downloadArchive(new ArchiveParams().tags(new String[]{ARCHIVE_TAG}).targetTags(new String[]{UPLOADER_TAG}));

cloudinary-test-common/src/main/java/com/cloudinary/test/MockableTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
public class MockableTest {
1212

1313
public static final String SRC_TEST_IMAGE = "../cloudinary-test-common/src/main/resources/old_logo.png";
14+
public static final String SRC_TEST_VIDEO = "http://res.cloudinary.com/demo/video/upload/dog.mp4";
15+
public static final String SRC_TEST_RAW = "../cloudinary-test-common/src/main/resources/docx.docx";
1416
public static final String REMOTE_TEST_IMAGE = "http://cloudinary.com/images/old_logo.png";
1517
protected static String SUFFIX = StringUtils.isNotBlank(System.getenv("TRAVIS_JOB_ID")) ? System.getenv("TRAVIS_JOB_ID") : String.valueOf(new Random().nextInt(99999));
1618
protected static final String SDK_TEST_TAG = "cloudinary_java_test_" + SUFFIX;

0 commit comments

Comments
 (0)