Utility function to prepare the items parameter, a list of
elements containing information about each file or folder to be imported
using the bulk_submit_import() method.
Usage
prepare_items_for_bulk_import(
volume_items,
destination_project = NULL,
destination_parent = NULL,
autorename = FALSE,
preserve_folder_structure = TRUE
)Arguments
- volume_items
A list of
VolumeFileorVolumePrefixobjects to be imported.- destination_project
Destination project ID or
Projectobject. Not required, but eitherdestination_projectordestination_parentdirectory must be provided.- destination_parent
Folder ID or
Fileobject (withtype = 'FOLDER'). Not required, but eitherdestination_projectordestination_parentdirectory must be provided.- autorename
Logical indicating whether to autorename conflicting files (default is
FALSE). Set toTRUEif you want to automatically rename the item (by prefixing its name with an underscore and number) if another one with the same name already exists at the destination. Bear in mind that if used with folders import, the folder content will be renamed, not the whole folder. Keep in mind that the sameautorenameoption will be applied to all items.- preserve_folder_structure
Logical indicating whether to preserve folder structure. Set to
TRUEif you want to keep the exact source folder structure. The default value isTRUEif the item being imported is a folder. Should not be used if you are importing a file. Bear in mind that if you usepreserve_folder_structure = FALSE, the response will be the parent folder object containing imported files alongside with other files if they exist. Keep in mind that the samepreserve_folder_structureoption will be applied to all folders.
Details
Based on the provided list of VolumeFile or
VolumePrefix objects, this function allows you to set the
following fields for each item:
source_volumesource_locationdestination_projectordestination_parentautorenamepreserve_folder_structure
However, keep in mind that there are certain constraints:
The same
destination_project/destination_parentselection applies to all items in the resulting list.The same applies to
autorenameandpreserve_folder_structureparameters.This function doesn't allow specification of the
nameof aliases to create. This is something that should be specified per item, therefore it cannot be applied to the entire list. However, once you have the output of theprepare_items_for_bulk_importfunction you can manually add thenamefield to certain items if necessary.
Examples
if (FALSE) { # \dontrun{
# Example 1: Prepare 2 items for bulk import action - provide destination
# project
volume_obj_1 <- a$volumes$get
volume_obj_2 <- a$volumes$get
volumes_to_import <- list(volume_obj_1, volume_obj_2)
destination_project <- a$projects$get(id = "project_id")
prepare_items_for_bulk_import(
volume_items = volumes_to_import,
destination_project = destination_project
)
} # }
if (FALSE) { # \dontrun{
# Example 2: Prepare 2 items for bulk import action - provide destination
# parent
volume_obj_1 <- a$volumes$get
volume_obj_2 <- a$volumes$get
volumes_to_import <- list(volume_obj_1, volume_obj_2)
destination_parent <- a$files$get(id = "folder_id")
prepare_items_for_bulk_import(
volume_items = volumes_to_import,
destination_parent = destination_parent
)
} # }