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
VolumeFile
orVolumePrefix
objects to be imported.- destination_project
Destination project ID or
Project
object. Not required, but eitherdestination_project
ordestination_parent
directory must be provided.- destination_parent
Folder ID or
File
object (withtype = 'FOLDER'
). Not required, but eitherdestination_project
ordestination_parent
directory must be provided.- autorename
Logical indicating whether to autorename conflicting files (default is
FALSE
). Set toTRUE
if 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 sameautorename
option will be applied to all items.- preserve_folder_structure
Logical indicating whether to preserve folder structure. Set to
TRUE
if you want to keep the exact source folder structure. The default value isTRUE
if 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_structure
option 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_volume
source_location
destination_project
ordestination_parent
autorename
preserve_folder_structure
However, keep in mind that there are certain constraints:
The same
destination_project
/destination_parent
selection applies to all items in the resulting list.The same applies to
autorename
andpreserve_folder_structure
parameters.This function doesn't allow specification of the
name
of 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_import
function you can manually add thename
field to certain items if necessary.
Examples
if (FALSE) {
# 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) {
# 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
)
}