Skip to content

Commit 8074d29

Browse files
Support multiple resource_types in ZIP generation (#348)
Support multiple resource_types in ZIP generation
1 parent a9e9218 commit 8074d29

File tree

5 files changed

+25
-2
lines changed

5 files changed

+25
-2
lines changed

lib-es5/utils/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,6 @@ function patchFetchFormat() {
665665
function url(public_id) {
666666
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
667667

668-
669668
var signature = void 0,
670669
source_to_sign = void 0;
671670
utils.patchFetchFormat(options);
@@ -1043,6 +1042,8 @@ function zip_download_url(tag) {
10431042
* @param {string|Array} [options.tags] list of tags to include in the archive
10441043
* @param {string|Array<string>} [options.public_ids] list of public_ids to include in the archive
10451044
* @param {string|Array<string>} [options.prefixes] list of prefixes of public IDs (e.g., folders).
1045+
* @param {string|Array<string>} [options.fully_qualified_public_ids] list of fully qualified public_ids to include
1046+
* in the archive.
10461047
* @param {string|Array<string>} [options.transformations] list of transformations.
10471048
* The derived images of the given transformations are included in the archive. Using the string representation of
10481049
* multiple chained transformations as we use for the 'eager' upload parameter.
@@ -1264,6 +1265,7 @@ function archive_params() {
12641265
mode: options.mode,
12651266
notification_url: options.notification_url,
12661267
prefixes: options.prefixes && toArray(options.prefixes),
1268+
fully_qualified_public_ids: options.fully_qualified_public_ids && toArray(options.fully_qualified_public_ids),
12671269
public_ids: options.public_ids && toArray(options.public_ids),
12681270
skip_transformation_name: exports.as_safe_bool(options.skip_transformation_name),
12691271
tags: options.tags && toArray(options.tags),

lib/utils/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,6 @@ function patchFetchFormat(options = {}) {
603603
}
604604

605605
function url(public_id, options = {}) {
606-
607606
let signature, source_to_sign;
608607
utils.patchFetchFormat(options);
609608
let type = consumeOption(options, "type", null);
@@ -957,6 +956,8 @@ function zip_download_url(tag, options = {}) {
957956
* @param {string|Array} [options.tags] list of tags to include in the archive
958957
* @param {string|Array<string>} [options.public_ids] list of public_ids to include in the archive
959958
* @param {string|Array<string>} [options.prefixes] list of prefixes of public IDs (e.g., folders).
959+
* @param {string|Array<string>} [options.fully_qualified_public_ids] list of fully qualified public_ids to include
960+
* in the archive.
960961
* @param {string|Array<string>} [options.transformations] list of transformations.
961962
* The derived images of the given transformations are included in the archive. Using the string representation of
962963
* multiple chained transformations as we use for the 'eager' upload parameter.
@@ -1161,6 +1162,7 @@ function archive_params(options = {}) {
11611162
mode: options.mode,
11621163
notification_url: options.notification_url,
11631164
prefixes: options.prefixes && toArray(options.prefixes),
1165+
fully_qualified_public_ids: options.fully_qualified_public_ids && toArray(options.fully_qualified_public_ids),
11641166
public_ids: options.public_ids && toArray(options.public_ids),
11651167
skip_transformation_name: exports.as_safe_bool(options.skip_transformation_name),
11661168
tags: options.tags && toArray(options.tags),

test/archivespec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ const helper = require("./spechelper");
1616
const { utils, api, uploader } = cloudinary.v2;
1717
const TEST_TAG = helper.TEST_TAG;
1818
const IMAGE_URL = helper.IMAGE_URL;
19+
const VIDEO_URL = helper.VIDEO_URL;
1920
const sharedExamples = helper.sharedExamples;
2021
const includeContext = helper.includeContext;
2122
const ARCHIVE_TAG = TEST_TAG + "_archive";
2223
const PUBLIC_ID1 = ARCHIVE_TAG + "_1";
2324
const PUBLIC_ID2 = ARCHIVE_TAG + "_2";
2425
const PUBLIC_ID_RAW = ARCHIVE_TAG + "_3";
26+
const FULLY_QUALIFIED_IMAGE = "image/upload/sample";
27+
const FULLY_QUALIFIED_VIDEO = "video/upload/dog";
2528

2629
sharedExamples('archive', function () {
2730
before("Verify Configuration", function () {
@@ -56,6 +59,12 @@ sharedExamples('archive', function () {
5659
resource_type: "raw",
5760
tags: helper.UPLOAD_TAGS.concat([ARCHIVE_TAG]),
5861
}),
62+
uploader.upload(VIDEO_URL,
63+
{
64+
public_id: "dog",
65+
resource_type: "video",
66+
tags: helper.UPLOAD_TAGS.concat([ARCHIVE_TAG]),
67+
}),
5968
]);
6069
});
6170
after(function () {
@@ -152,6 +161,14 @@ describe("archive", function () {
152161
sinon.assert.calledWith(write, sinon.match(helper.uploadParamMatcher("target_format", "zip")));
153162
});
154163
});
164+
it('should create archive with "zip" format and include multiple resource types', function () {
165+
return uploader.create_zip({
166+
fully_qualified_public_ids: [FULLY_QUALIFIED_IMAGE, FULLY_QUALIFIED_VIDEO],
167+
resource_type: "auto",
168+
}).then((result) => {
169+
expect(result.file_count).to.eql(2);
170+
});
171+
});
155172
});
156173
});
157174
});

test/spechelper.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ exports.LARGE_VIDEO = "test/resources/CloudBookStudy-HD.mp4";
3636
exports.EMPTY_IMAGE = "test/resources/empty.gif";
3737
exports.RAW_FILE = "test/resources/docx.docx";
3838
exports.ICON_FILE = "test/resources/favicon.ico";
39+
exports.VIDEO_URL = "http://res.cloudinary.com/demo/video/upload/dog.mp4";
3940
exports.IMAGE_URL = "http://res.cloudinary.com/demo/image/upload/sample";
4041

4142
exports.test_cloudinary_url = function (public_id, options, expected_url, expected_options) {

types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ declare module 'cloudinary' {
408408
notification_url?: string;
409409
prefixes?: string;
410410
public_ids?: string[] | string;
411+
fully_qualified_public_ids?: string[] | string;
411412
skip_transformation_name?: boolean;
412413
tags?: string | string[];
413414
target_format?: TargetArchiveFormat;

0 commit comments

Comments
 (0)