Skip to content

Allow generating archive with multiple resource types #174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 16, 2019
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
13 changes: 13 additions & 0 deletions cloudinary-core/src/main/java/com/cloudinary/ArchiveParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class ArchiveParams {
private String[] targetTags = null;
private String[] tags = null;
private String[] publicIds = null;
private String[] fullyQualifiedPublicIds = null;
private String[] prefixes = null;
private Transformation[] transformations = null;
private Long expiresAt = null;
Expand Down Expand Up @@ -176,6 +177,15 @@ public ArchiveParams publicIds(String[] publicIds) {
return this;
}

public String[] fully_qualified_public_ids() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method names in java must be camelCase (fullyQualifiedPublicIds()) even if the string in the hash is actually underscores.

return fullyQualifiedPublicIds;
}

public ArchiveParams fullyQualifiedPublicIds(String[] fullyQualifiedPublicIds) {
this.fullyQualifiedPublicIds = fullyQualifiedPublicIds;
return this;
}

public String[] prefixes() {
return prefixes;
}
Expand Down Expand Up @@ -225,6 +235,9 @@ public Map<String, Object> toMap() {
params.put("tags", tags);
if (publicIds != null)
params.put("public_ids", publicIds);
if(fullyQualifiedPublicIds !=null){
params.put("fully_qualified_public_ids", fullyQualifiedPublicIds);
}
if (prefixes != null)
params.put("prefixes", prefixes);
if (transformations != null) {
Expand Down
1 change: 1 addition & 0 deletions cloudinary-core/src/main/java/com/cloudinary/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public static final Map<String, Object> buildArchiveParams(Map options, String t
putArray("target_tags", options, params);
putArray("tags", options, params);
putArray("public_ids", options, params);
putArray("fully_qualified_public_ids", options, params);
putArray("prefixes", options, params);
putEager("transformations", options, params);
putObject("timestamp", options, params, Util.timestamp());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ abstract public class AbstractUploaderTest extends MockableTest {
public static final int SRC_TEST_IMAGE_W = 241;
public static final int SRC_TEST_IMAGE_H = 51;
private static Map<String, Set<String>> toDelete = new HashMap<String, Set<String>>();
public static final String SRC_FULLY_QUALIFIED_IMAGE="image/upload/sample";
public static final String SRC_FULLY_QUALIFIED_VIDEO="video/upload/dog";

@BeforeClass
public static void setUpClass() throws IOException {
Expand All @@ -38,6 +40,7 @@ public static void setUpClass() throws IOException {
}

cloudinary.uploader().upload(SRC_TEST_IMAGE, asMap("tags", new String[]{SDK_TEST_TAG, UPLOADER_TAG, ARCHIVE_TAG}));
cloudinary.uploader().upload(SRC_TEST_VIDEO, asMap("tags", new String[]{SDK_TEST_TAG, UPLOADER_TAG, ARCHIVE_TAG}, "public_id", "dog", "resource_type", "video"));
cloudinary.uploader().upload(SRC_TEST_IMAGE, asMap("tags", new String[]{SDK_TEST_TAG, UPLOADER_TAG, ARCHIVE_TAG}, "resource_type", "raw"));
cloudinary.uploader().upload(SRC_TEST_IMAGE,
asMap("tags", new String[]{SDK_TEST_TAG, UPLOADER_TAG, ARCHIVE_TAG},
Expand Down Expand Up @@ -591,6 +594,13 @@ public void testCreateArchiveRaw() throws Exception {

}

@Test
public void testCreateZipMultipleResourceTypes() throws Exception {
Map result = cloudinary.uploader().createZip(ObjectUtils.asMap("fully_qualified_public_ids",(new String[]{SRC_FULLY_QUALIFIED_IMAGE,SRC_FULLY_QUALIFIED_VIDEO}),"resource_type","auto"));
assertEquals(2, result.get("file_count"));
cloudinary.api().deleteResources(Arrays.asList(result.get("public_id").toString()), asMap("resource_type", "raw"));
}

@Test
public void testDownloadArchive() throws Exception {
String result = cloudinary.downloadArchive(new ArchiveParams().tags(new String[]{ARCHIVE_TAG}).targetTags(new String[]{UPLOADER_TAG}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
public class MockableTest {

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