|
23 | 23 | @option("-f", "--folder", default="", |
24 | 24 | help="The Cloudinary folder where you want to upload the assets. " |
25 | 25 | "You can specify a whole path, for example folder1/folder2/folder3. " |
26 | | - "Any folders that do not exist are automatically created.") |
| 26 | + "If your product environment uses fixed folder mode, then any folders that do not exist are automatically created.") |
27 | 27 | @option("-p", "--preset", help="The upload preset to use.") |
| 28 | +@option("-e", "--exclude-dir-name", is_flag=True, default=False, |
| 29 | + help="Don't include the selected parent directory name in the public ID path of the uploaded files." |
| 30 | + "This ensures that the public ID paths of the uploaded assets will be directly under the specified --(f)older, avoiding an extraneous level in the path." |
| 31 | + "When this option is used, the contents of the parent directory are uploaded instead of the parent directory itself and thus the name of the specified parent directory is not included in the pubic ID path of the uploaded assets.") |
28 | 32 | @option("-w", "--concurrent_workers", type=int, default=30, help="Specify the number of concurrent network threads.") |
29 | 33 | def upload_dir(directory, glob_pattern, include_hidden, optional_parameter, optional_parameter_parsed, transformation, |
30 | | - folder, preset, concurrent_workers): |
| 34 | + folder, preset, concurrent_workers, exclude_dir_name): |
31 | 35 | items, skipped = {}, {} |
32 | 36 |
|
33 | 37 | dir_to_upload = Path(path_join(getcwd(), directory)) |
34 | 38 | if not dir_to_upload.exists(): |
35 | 39 | logger.error(f"Directory: {dir_to_upload} does not exist") |
36 | 40 | return False |
37 | 41 |
|
38 | | - logger.info(f"Uploading directory '{dir_to_upload}'") |
39 | | - parent = dirname(dir_to_upload) |
| 42 | + if exclude_dir_name: |
| 43 | + logger.info(f"Uploading contents of directory '{dir_to_upload}'") |
| 44 | + parent = dir_to_upload |
| 45 | + else: |
| 46 | + logger.info(f"Uploading directory '{dir_to_upload}'") |
| 47 | + parent = dirname(dir_to_upload) |
| 48 | + |
40 | 49 | options = { |
41 | 50 | **{k: v for k, v in optional_parameter}, |
42 | 51 | **{k: parse_option_value(v) for k, v in optional_parameter_parsed}, |
|
0 commit comments