Skip to content

Commit b7868de

Browse files
support target_asset_folder for generate archive (#717)
1 parent e306a41 commit b7868de

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

lib/utils/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,8 @@ function api_download_url(action, params, options) {
12841284
* @param {string} [options.target_format="zip"]
12851285
* @param {string} [options.target_public_id] public ID of the generated raw resource.
12861286
* Relevant only for the create mode. If not specified, random public ID is generated.
1287+
* @param {string} [options.target_asset_folder] The folder where the generated file is placed within the Cloudinary repository.
1288+
* Not supported for product environments using the legacy fixed folder mode
12871289
* @param {boolean} [options.flatten_folders=false] If true, flatten public IDs with folders to be in the root
12881290
* of the archive. Add numeric counter to the file name in case of a name conflict.
12891291
* @param {boolean} [options.flatten_transformations=false] If true, and multiple transformations are given,
@@ -1506,6 +1508,7 @@ function archive_params(options = {}) {
15061508
tags: options.tags && toArray(options.tags),
15071509
target_format: options.target_format,
15081510
target_public_id: options.target_public_id,
1511+
target_asset_folder: options.target_asset_folder,
15091512
target_tags: options.target_tags && toArray(options.target_tags),
15101513
timestamp: options.timestamp || exports.timestamp(),
15111514
transformations: utils.build_eager(options.transformations),

test/integration/api/uploader/archivespec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const PUBLIC_ID2 = ARCHIVE_TAG + "_2";
3737
const PUBLIC_ID_RAW = ARCHIVE_TAG + "_3";
3838
const FULLY_QUALIFIED_IMAGE = "image/upload/sample";
3939
const FULLY_QUALIFIED_VIDEO = "video/upload/dog";
40-
40+
const TARGET_ASSET_FOLDER = 'test-folder';
4141

4242
describe("archive", function () {
4343
this.timeout(TIMEOUT.LONG);
@@ -155,12 +155,14 @@ describe("archive", function () {
155155
tags: TEST_TAG,
156156
public_ids: [PUBLIC_ID_RAW, "non-existing-resource"],
157157
resource_type: "raw",
158-
allow_missing: true
158+
allow_missing: true,
159+
target_asset_folder: TARGET_ASSET_FOLDER
159160
});
160161
sinon.assert.calledWith(writeSpy, sinon.match(helper.uploadParamMatcher("tags[]", TEST_TAG)));
161162
sinon.assert.calledWith(writeSpy, sinon.match(helper.uploadParamMatcher("public_ids[]", PUBLIC_ID_RAW)));
162163
sinon.assert.calledWith(writeSpy, sinon.match(helper.uploadParamMatcher("public_ids[]", "non-existing-resource")));
163164
sinon.assert.calledWith(writeSpy, sinon.match(helper.uploadParamMatcher("allow_missing", 1)));
165+
sinon.assert.calledWith(writeSpy, sinon.match(helper.uploadParamMatcher("target_asset_folder", TARGET_ASSET_FOLDER)));
164166
sinon.assert.calledWith(writeSpy, sinon.match(helper.uploadParamMatcher("target_format", "zip")));
165167
});
166168
});

types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ declare module 'cloudinary' {
428428
tags?: string | string[];
429429
target_format?: TargetArchiveFormat;
430430
target_public_id?: string;
431+
target_asset_folder?: string;
431432
target_tags?: string[];
432433
timestamp?: number;
433434
transformations?: TransformationOptions;

0 commit comments

Comments
 (0)