Skip to content

Commit

Permalink
Add support for folder decoupling (#523)
Browse files Browse the repository at this point in the history
  • Loading branch information
YomesInc authored Jan 2, 2022
1 parent 57338ff commit 2d0a046
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib-es5/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,13 @@ function build_upload_params(options) {
var params = {
access_mode: options.access_mode,
allowed_formats: options.allowed_formats && toArray(options.allowed_formats).join(","),
asset_folder: options.asset_folder,
async: utils.as_safe_bool(options.async),
backup: utils.as_safe_bool(options.backup),
callback: options.callback,
cinemagraph_analysis: utils.as_safe_bool(options.cinemagraph_analysis),
colors: utils.as_safe_bool(options.colors),
display_name: options.display_name,
discard_original_filename: utils.as_safe_bool(options.discard_original_filename),
eager: utils.build_eager(options.eager),
eager_async: utils.as_safe_bool(options.eager_async),
Expand All @@ -372,6 +374,7 @@ function build_upload_params(options) {
phash: utils.as_safe_bool(options.phash),
proxy: options.proxy,
public_id: options.public_id,
public_id_prefix: options.public_id_prefix,
quality_analysis: utils.as_safe_bool(options.quality_analysis),
responsive_breakpoints: utils.generate_responsive_breakpoints_string(options.responsive_breakpoints),
return_delete_token: utils.as_safe_bool(options.return_delete_token),
Expand All @@ -381,6 +384,7 @@ function build_upload_params(options) {
unique_filename: utils.as_safe_bool(options.unique_filename),
upload_preset: options.upload_preset,
use_filename: utils.as_safe_bool(options.use_filename),
use_filename_as_display_name: utils.as_safe_bool(options.use_filename_as_display_name),
quality_override: options.quality_override,
accessibility_analysis: utils.as_safe_bool(options.accessibility_analysis)
};
Expand Down
4 changes: 4 additions & 0 deletions lib/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,13 @@ function build_upload_params(options) {
let params = {
access_mode: options.access_mode,
allowed_formats: options.allowed_formats && toArray(options.allowed_formats).join(","),
asset_folder: options.asset_folder,
async: utils.as_safe_bool(options.async),
backup: utils.as_safe_bool(options.backup),
callback: options.callback,
cinemagraph_analysis: utils.as_safe_bool(options.cinemagraph_analysis),
colors: utils.as_safe_bool(options.colors),
display_name: options.display_name,
discard_original_filename: utils.as_safe_bool(options.discard_original_filename),
eager: utils.build_eager(options.eager),
eager_async: utils.as_safe_bool(options.eager_async),
Expand All @@ -351,6 +353,7 @@ function build_upload_params(options) {
phash: utils.as_safe_bool(options.phash),
proxy: options.proxy,
public_id: options.public_id,
public_id_prefix: options.public_id_prefix,
quality_analysis: utils.as_safe_bool(options.quality_analysis),
responsive_breakpoints: utils.generate_responsive_breakpoints_string(options.responsive_breakpoints),
return_delete_token: utils.as_safe_bool(options.return_delete_token),
Expand All @@ -360,6 +363,7 @@ function build_upload_params(options) {
unique_filename: utils.as_safe_bool(options.unique_filename),
upload_preset: options.upload_preset,
use_filename: utils.as_safe_bool(options.use_filename),
use_filename_as_display_name: utils.as_safe_bool(options.use_filename_as_display_name),
quality_override: options.quality_override,
accessibility_analysis: utils.as_safe_bool(options.accessibility_analysis)
};
Expand Down
22 changes: 22 additions & 0 deletions test/integration/api/uploader/uploader_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,28 @@ describe("uploader", function () {
});
});
});
describe("folder decoupling", () => {
const mocked = helper.mockTest();
it('should pass folder decoupling params', () => {
const public_id_prefix = "fd_public_id_prefix";
const asset_folder = "asset_folder";
const display_name = "display_name";
const use_filename_as_display_name = true;
const folder = "folder/test";
UPLOADER_V2.upload(IMAGE_FILE, {
public_id_prefix,
asset_folder,
display_name,
use_filename_as_display_name,
folder
});
sinon.assert.calledWithMatch(mocked.write, helper.uploadParamMatcher("public_id_prefix", public_id_prefix));
sinon.assert.calledWithMatch(mocked.write, helper.uploadParamMatcher("asset_folder", asset_folder));
sinon.assert.calledWithMatch(mocked.write, helper.uploadParamMatcher("display_name", display_name));
sinon.assert.calledWithMatch(mocked.write, helper.uploadParamMatcher("use_filename_as_display_name", 1));
sinon.assert.calledWithMatch(mocked.write, helper.uploadParamMatcher("folder", folder));
});
});
it("should support unsigned uploading using presets", async function () {
this.timeout(TIMEOUT.LONG);

Expand Down

0 comments on commit 2d0a046

Please sign in to comment.