File Commands - pilotcli file
File commands for the pilotcli command line tool.
File Commands: pilotcli file
Help
$ pilotcli file --help
Usage: pilotcli_windows file [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
attribute-export Export attribute template from a given Project.
attribute-list List attribute templates of a given Project.
download Download files/folders from a given Project/folder/file...
list List files and folders inside a given Project/folder.
metadata Download metadata file of a given file in target zone.
move Move/Rename files/folders to a given Project path.
resume Resume the upload process with a resumable upload log.
trash Move files/folders to trash bin.
upload Upload files/folders to a given Project path (eg.Command: attribute-export
Options:
-p --project-code,-n --attribute-nameUsage: Export an attribute from given Project by attribute name
Output:
(1) Attribute Template JSON file
(2) Attribute Definition JSON file
Prerequisites:
User login is required, otherwise error is returned: "The current login session is invalid. Please login to continue."
Project must be accessible to the user, otherwise, error is returned: "Project Code not found in list. Please verify and try again."
Requires the Project Code (retrieved via
pilotcli project list).Requires that the Attribute Template exists. If Attribute Template does not exist or is spelled incorrectly, the following error is returned: "Attribute 'sample-template' not found in Project. Please verify and try again."
pilotclimust have permission to write file in the directory
$ pilotcli file attribute-export --help
Usage: pilotcli_linux file attribute-export [OPTIONS]
Export attribute template from a given Project.
Options:
-p, --project-code TEXT Project Code
-n, --attribute-name TEXT Attribute Template Name
--help Show this message and exit.Examples
(1) Export attributes from a given Project by attribute name:
Directly export an attribute by name from a given project
Denoting the project options are not required in the command explicitly, however if they are not included you will be prompted to enter them
Command structure: pilotcli file attribute-export
example: pilotcli file attribute-export
$ pilotcli file attribute-export
ProjectCode: <Enter-Project-Code>
AttributeName: <Enter-Attribute-Template-Name>
Attribute-Template-Name
--------------------------------------------------------------------------
| Attribute Name | Type | Value | Optional |
--------------------------------------------------------------------------
| attr1 | multiple_choice | a1,a2,a3,a4,a5 | False |
--------------------------------------------------------------------------
| attr2 | text | None | False |
--------------------------------------------------------------------------
| attr3 | multiple_choice | t1,t2,t3,t4,t5 | True |
--------------------------------------------------------------------------
Template saved successfully: Project-Code_Attribute-Template-Name_template.json
Attribute definition saved successfully: Project-Code_Attribute-Template-Name_definition.json(2) Export attributes from a given Project by attribute name with options:
Directly export an attribute by name from a given project, including the options in the command itself.
Command structure: pilotcli file attribute-export -p <project code> -n <attribute template name>
example: pilotcli file attribute-export -p IndocTestProject -n IMG_CoreMetadata
$ pilotcli file attribute-export -p Project-Code -n Attribute-Template-Name
Attribute-Template-Name
--------------------------------------------------------------------------
| Attribute Name | Type | Value | Optional |
--------------------------------------------------------------------------
| attr1 | multiple_choice | a1,a2,a3,a4,a5 | False |
--------------------------------------------------------------------------
| attr2 | text | None | False |
--------------------------------------------------------------------------
| attr3 | multiple_choice | t1,t2,t3,t4,t5 | True |
--------------------------------------------------------------------------
Template saved successfully: Project-Code_Attribute-Template-Name_template.json
Attribute definition saved successfully: Project-Code_Attribute-Template-Name_definition.jsonCommand: attribute-list
Options: -p --project-code
Usage: List all attributes from given Project
Prerequisite:
User login is required, otherwise error is returned: βThe current login session is invalid. Please login to continue.β
Requires the Project code (retrieved via
pilotcli project list).
$ pilotcli file attribute-list --help
Usage: pilotcli file attribute-list [OPTIONS]
List attribute templates of a given Project.
Options:
-p, --project-code TEXT Project Code
--help Show this message and exit.Examples
(1) List attributes from a given Project:
Generate a list of attributes in any given project.
Denoting the project options are not required in the command explicitly, however if they are not included you will be prompted to enter them
Command structure: pilotcli file attribute-list
example: pilotcli file attribute-list
$ pilotcli file attribute-list
ProjectCode: <Enter-Project-Code>
Attribute-Template-Name
--------------------------------------------------------------------------
| Attribute Name | Type | Value | Optional |
--------------------------------------------------------------------------
| attr1 | multiple_choice | a1,a2,a3,a4,a5 | False |
--------------------------------------------------------------------------
| attr2 | text | None | False |
--------------------------------------------------------------------------
| attr3 | single_choice | t1,t2,t3,t4,t5 | True |
--------------------------------------------------------------------------
Attribute-Template-Name2
--------------------------------------------------------------------------
| Attribute Name | Type | Value | Optional |
--------------------------------------------------------------------------
| attr1 | multiple_choice | a1,a2,a3,a4 | True |
--------------------------------------------------------------------------
| attr2 | text | None | False |
--------------------------------------------------------------------------
| attr3 | single_choice | t1,t2,t3 | True |
--------------------------------------------------------------------------
All Attributes fetched successfully.(2) List attributes from a given Project with options:
Directly generate a list of attributes from a given project, including the options in the command itself.
Command structure: pilotcli file attribute-list -p <project code>
example: pilotcli file attribute-list -p IndocTestProject
$ pilotcli file attribute-list -p <Project-Code>
Attribute-Template-Name
--------------------------------------------------------------------------
| Attribute Name | Type | Value | Optional |
--------------------------------------------------------------------------
| attr1 | multiple_choice | a1,a2,a3,a4,a5 | False |
--------------------------------------------------------------------------
| attr2 | text | None | False |
--------------------------------------------------------------------------
| attr3 | single_choice | t1,t2,t3,t4,t5 | True |
--------------------------------------------------------------------------
Attribute-Template-Name2
--------------------------------------------------------------------------
| Attribute Name | Type | Value | Optional |
--------------------------------------------------------------------------
| attr1 | multiple_choice | a1,a2,a3,a4 | True |
--------------------------------------------------------------------------
| attr2 | text | None | False |
--------------------------------------------------------------------------
| attr3 | single_choice | t1,t2,t3 | True |
--------------------------------------------------------------------------
All Attributes fetched successfully.Command: download
Usage: Download a file/folder from a Project using a full path: project code/folder type (users vs. shared)/folder name/file or folder name (i.e.,
indoctestproject/users/username/folder1/file.csv)Options:
-z --zone, -i --geid, --zipTo look up a fileβs
geid, or unique file ID, open the Project File Explorer in the Portal and inspect the File Properties for the ID.
Prerequisite:
User login is required, otherwise error is returned: "The current login session is invalid. Please login to continue."
File/folder must exist, otherwise error is returned: βFile does not exist or source file provided is invalid: folder_name/file_name.β
If user has no access to the file/folder on the Portal, an error is returned: βPermission denied. Please verify that your role in the Project has permission to perform this action.β
Please be aware of the applicable zone restrictions depending on where you are using the pilotcli: https://indocconsortium.atlassian.net/wiki/spaces/JSDNXT/pages/4317710124
$ pilotcli file download --help
Usage: pilotcli_linux file download [OPTIONS] [PATHS]... OUTPUT_PATH
Download files/folders from a given Project/folder/file in core zone.
Options:
-z, --zone TEXT Target Zone (i.e., core/greenroom).
--zip Download files as a zip.
-i, --geid Enable downloading by geid.
--help Show this message and exit.Examples
(1) Download file/folder from Green Room
Downloading a file/folder from Green Room with download command requires the environment variable to be configured, and pilotcli will prevent upload of duplicate file names (case insensitive). If user inputs multiple file/folder names, these files or folders will be downloaded one by one to the given directory.
Command structure: pilotcli file download <project code>/<folder type> (users or shared)/<folder name>/<file or folder name> <file output location>
example: pilotcli file download indoctestproject/shared/IMG/test.csv ~/Documents
$ pilotcli file download indoctestproject/users/admin/sample_file2 cli/admin/sample_file7 ~/Downloads
Preparing status: READY_FOR_DOWNLOADING
/home/uname/Downloads/sample_file2 already exist, file will be saved as /home/uname/Downloads/sample_file2 (1)
start downloading...
Downloading sample_file2 (1) |ββββββββββββββββββββββββββββββ 100% 00:00
File has been downloaded successfully and saved to: /home/uname/Downloads/sample_file2 (1)
Preparing status: READY_FOR_DOWNLOADING
start downloading...
Downloading sample_file7 |ββββββββββββββββββββββββββββββ 100% 00:00
File has been downloaded successfully and saved to: /home/uname/Downloads/sample_file7(2) Download file/folder from Core
Use the download command to download a file/folder from Core with option
-z or --zone.Command structure: pilotcli file download <project code>/<folder type> (users or shared)/<folder name>/<file or folder name> -z <zone> (i.e., greenroom or core) <file output location>
example: pilotcli file download indoctestproject/shared/IMG/test.csv -z core ~/Documents
$ pilotcli file download testproject/shared/admin/sample_file2 -z core ~/Downloads/
Preparing status: READY_FOR_DOWNLOADING
start downloading...
Downloading sample_file2 |ββββββββββββββββββββββββββββββ 100% 00:00
File has been downloaded successfully and saved to: /home/uname/Downloads/sample_file2(3) Download multiple files/folders as a compressed zip
Use the download command to download multiple files/folders as a compressed zip file with option
--zip.Command structure: pilotcli file download <project code>/<folder type> (users or shared)/<folder name>/<file or folder name> -z <zone> (i.e., greenroom or core) <file output location> --zip
example: pilotcli file download indoctestproject/shared/IMG/test.csv -z core ~/Documents
--zip
$ pilotcli file download testproject/shared/admin/sample_file2 cli/admin/sample_file7 -z core ~/Downloads/ --zip
Preparing downloading
Preparing status: READY_FOR_DOWNLOADING
start downloading...
Downloading cli_1632340658.768384.zip |ββββββββββββββββββββββββββββββ 100% 00:00
File has been downloaded successfully and saved to: /home/uname/Downloads/cli_1632340658.768384.zip(4) Download file/folder by geid
Use the download command to download file(s)/folder(s) by
geidwith option-i --geid. The option -z --zone is not required when downloading bygeid.Command structure: pilotcli file download -i <geid from file 1> <geid from file 2> <file output location>
example pilotcli file download -i 6d89afd4-f86e-4df7-b6c5-01a9af4e828e-1627499957 7e8e2bac-97c6-4738-bc08-12139c9ba225-1627498854 ~/Documents
$ pilotcli file download -i 6d89afd4-f86e-4df7-b6c5-01a9af4e828e-1627499957 7e8e2bac-97c6-4738-bc08-12139c9ba225-1627498854 ~/Downloads/
Preparing status: READY_FOR_DOWNLOADING
start downloading...
Downloading sample_file7 |ββββββββββββββββββββββββββββββ 100% 00:00
File has been downloaded successfully and saved to: /home/uname/Downloads/sample_file7
Preparing status: READY_FOR_DOWNLOADING
start downloading...
Downloading sample_file2 |ββββββββββββββββββββββββββββββ 100% 00:00
File has been downloaded successfully and saved to: /home/uname/Downloads/sample_file2If the
--zipoption is used then command interface will automatically group inputgeidby the project, zone and then download as different zip files.Command structure: pilotcli file download -i <geid from file 1> <geid from file 2> <file output location> --zip
example: pilotcli file download -i 6d89afd4-f86e-4df7-b6c5-01a9af4e828e-1627499957 7e8e2bac-97c6-4738-bc08-12139c9ba225-1627498854 ~/Documents --zip
$ pilotcli file download -i --zip 6d89afd4-f86e-4df7-b6c5-01a9af4e828e-1627499957 7e8e2bac-97c6-4738-bc08-12139c9ba225-1627498854 228ec18b-6775-443d-a69e-6c491b240b98-1627498776 25f0ede8-859e-4320-8e53-83921aa9a6be-1627499276 ~/Downloads/ --zip
Preparing downloading
Preparing status: READY_FOR_DOWNLOADING
start downloading...
Downloading cli_1632341269.0496638.zip |ββββββββββββββββββββββββββββββ 100% 00:00
File has been downloaded successfully and saved to: /home/uname/Downloads/cli_1632341269.0496638.zip
Preparing status: READY_FOR_DOWNLOADING
start downloading...
Downloading cli_1632341274.5802007.zip |ββββββββββββββββββββββββββββββ 100% 00:00
File has been downloaded successfully and saved to: /home/uname/Downloads/cli_1632341274.5802007.zipCommand: list
Options:
-z --zoneUsage: List files and folders in the directory. Folders will be displayed in blue and files will be displayed in white.
Prerequisite:
User login is required, otherwise error is returned: "The current login session is invalid. Please login to continue."
Project must be accessible to the user, otherwise, error is returned: "Project Code not found in list. Please verify and try again."
Requires the Project code (retrieved via
pilotcli project list) and path.Requires indicating whether the folder is a shared folder or a user folder in the file path. Not denoting this will return only two options
shared users
By default, only the first ten elements will be displayed. If you have access to more than ten files/folders in a certain Project, you will be prompted to use your arrow keys to select one of two options to either view the next ten items (next page), or to exit (exit) to return to the command line. The selected option is indicated by two arrows and can be confirmed by hitting enter:
What do you want? (Use arrow keys)
Β» next page
exit$ pilotcli file list --help
Usage: pilotcli_linux file list [OPTIONS] PATHS
List files and folders inside a given Project/folder.
Options:
-z, --zone TEXT Target Zone (i.e., core/greenroom). [default:
greenroom]
--page INTEGER The page to be listed [default: 0]
--page-size INTEGER number of objects per page [default: 10]
-d, --detached whether run in detached mode
--help Show this message and exit.Examples
(1) List files/folders in a Green Room user folder
List all files/folders in a Green Room folder
-z is not required, however you must denote whether the folder is a shared folder or a user folder in the path in order to return the file/folder list
Command structure: pilotcli file list <project code>/<folder type> (users or shared)/<folder name>
example: pilotcli file list indoctestproject/shared/IMG
$ pilotcli file list indoctestproject/users/admin
test_folder1 test_folder2 file1 file2 file3(2) List files/folders in a Core shared folder
List all files/folders in a Core folder
Command structure: pilotcli file list <project code>/<folder type> (users or shared)/<folder name> -z <zone> (i.e., greenroom or core)
example: pilotcli file list indoctestproject/shared/IMG -z core
$ pilotcli file list indoctestproject/shared/admin -z core
folder1 folder2 test_folder.zip file.txt sample.txt large-file.jsonΒ
(3) List files/folders in Trash Bin from the Green Room
List all files/folders in the Trash Bin from the Green Room
Non-administrator users with access to the Trash Bin can only view the files they have moved to trash. Platform and Project Administrators can view the files in the Trash Bin from all Project members.
Command structure: pilotcli file list <project code>/trash -z greenroom
example: pilotcli file list indoctestproject/trash -z greenroom
$ pilotcli file list indoctestproject/trash -z greenroom
folder1 folder2 test_folder.zip file.txt sample.txt large-file.json(3) List files/folders in Trash Bin from the Core
List all files/folders in the Trash Bin from the core
Non-administrator users with access to the Trash Bin can only view the files they have moved to trash. Platform and Project Administrators can view the files in the Trash Bin from all Project members.
Command structure: pilotcli file list <project code>/trash -z core
example: pilotcli file list indoctestproject/trash -z core
$ pilotcli file list indoctestproject/trash -z core
folder1 folder2 test_folder.zip file.txt sample.txt large-file.jsonCommand: metadata
Usage: Download a fileβs metadata including properties, attributes, and tags.
Options:
-z --zone,-g --general,-a --attribute,-t --tagOutput:
(1) attribute.json - a file containing the fileβs attributes
{ "<template_name>": { "<attribute_1>": "<value_1>", } }
(2) general.json - a file containing the fileβs general metadata
#sample general.json file { "id": "40219ea6-ef6a-436a-8458-2d654b27e239", "parent": "ff009692-537b-45da-b74a-a4255adf5eec", "parent_path": "users/blasalandra", "restore_path": null, "status": "ACTIVE", "type": "file", "zone": 0, "name": "TestFile.pdf", "size": 128000, "owner": "blasalandra", "container_code": "indoctestproject", "container_type": "project", "created_time": "2024-03-20 17:28:58.365001", "last_updated_time": "2024-03-20 17:29:00.690349", "storage": { "id": "2db51316-2d7d-40a9-96a8-dfe05ca2ea2a", "version": null, "upload_id": "a353b5de-53a2-46e6-9ca8-be3dd34e5cba" }, "favourite": false }
(3) tag.json
["tag1", "tag2", "tag3"]
Prerequisites:
User login is required, otherwise error is returned: "The current login session is invalid. Please login to continue."
File must exist, otherwise error is returned: βFile does not exist or source file provided is invalid: folder_name/file_name.β
If user has no access to the file/folder on the Portal, an error is returned: βPermission denied. Please verify that your role in the Project has permission to perform this action.β
$ pilotcli file metadata --help
Usage: pilotcli_linux file metadata [OPTIONS] FILE_PATH
Download metadata file of a given file in target zone.
Options:
-z, --zone TEXT Target Zone (i.e., core/greenroom). [required]
-g, --general TEXT The location of general metadata file [required]
-a, --attribute TEXT The location of attribute metadata file [required]
-t, --tag TEXT The location of tag metadata file [required]
--help Show this message and exit.(1) Download a file with general metadata, attributes, and tags.
Download file metadata in the form of: attribute.json, general.json, tags.json
Command structure: pilotcli file metadata -g . -a . -t . -z <zone> (i.e., greenroom or core) <project code>/<folder type> (users or shared)/<folder name>/<file or folder name>
example: pilotcli file metadata -g . -a . -t . -z core indoctestproject/shared/IMG/testfile.csv
$ pilotcli file metadata -g . -a . -t . -z core projectcode/users/username/folder/mock_csvfile.csv
Metadata download complete.Β
Command: move
Options:
-z --zoneUsage: Move/rename files/folders to a given Project Path within the same project
Prerequisite:
User login is required, otherwise error is returned: "The current login session is invalid. Please login to continue."
Project must be accessible to the user, otherwise, error is returned: "Project Code not found in list. Please verify and try again."
Project path must include the project folder type (i.e., shared or users).
When moving a file to the Project Core, user must have access to the Core (Project Contributors cannot move files/folders to the Project Core).
This command cannot be used to generate a new folder within a user or shared top-level folder. To create a new folder, please see the Folder Commands - pilotcli folder.
$ pilotcli file move --help
Usage: pilotcli_linux file move [OPTIONS] SRC_ITEM_PATH DEST_ITEM_PATH
Move/Rename files/folders to a given Project path.
Options:
-z, --zone TEXT Target Zone (i.e., core/greenroom). [required]
--help Show this message and exit.Examples
(1) Move a file from one folder to another within a Green Room Project
Move a file from one folder to another folder within that same project in the project Greenroom.
When moving/renamine a file within the project Greenroom, -z is not required.
Command structure: pilotcli file move <project code>/<origin folder type> (users or shared)/<origin folder name>/<file or folder name> <project code>/<destination folder type> (users or shared)/<destination folder name>
example: pilotcli file move indoctestproject/shared/IMG/test.csv indoctestproject/users/blasalandra/
$ pilotcli file move indoctestproject/users/blasalandra/test indoctestproject/shared/SharedFolder
Successfully moved indoctestproject/users/blasalandra/test to indoctestproject/shared/SharedFolder(2) Move a file from one folder to another within a Core Project
Move a file from one folder to another folder within the same project in the project core zone.
Command structure: pilotcli file move <project code>/<origin folder type> (users or shared)/<origin folder name>/<file or folder name> <project code>/<destination folder type> (users or shared)/<destination folder name> -z <zone> (i.e., greenroom or core)
example: pilotcli file move indoctestproject/shared/IMG/test.csv indoctestproject/users/blasalandra -z core
$ pilotcli file move indoctestproject/users/blasalandra/test indoctestproject/shared/SharedFolderCore -z core
Successfully moved indoctestproject/users/blasalandra/test to indoctestproject/shared/SharedFolderCore/test(3) Rename a file in a Green Room folder
Rename a file from the command line using the move command.
Command structure: pilotcli file move<project code>/<folder type> (users or shared)/<folder name>/<original file or folder name> <project code>/<folder type> (users or shared)/<folder name>/ <new file or folder name>
example: pilotcli file move indoctestproject/shared/IMG/test.csv indoctestproject/shared/IMG/newfile.csv
$ pilotcli file move indoctestproject/shared/test/testfile indoctestproject/shared/test/newfilename
Successfully moved indoctestproject/shared/test/testfile to indoctestproject/shared/test/newfilenameCommand: resume
Options:
-td --thread,-r --resumable-manifestUsage: Upload unfinished file/folder uploading based on the resumable upload file (
resumable_upload_log.json)Prerequisite:
User login is required, otherwise error is returned: "The current login session is invalid. Please login to continue."
Project must be accessible to the user, otherwise, error is returned: "Project Code not found in list. Please verify and try again."
Resumable upload manifest file is required, which is generated from using the
file uploadcommand (see example 10 above)[default: ./resumable_upload_log.json]
Please note incomplete uploads will be purged and removed from Pilot after 24 hours. Resumable files can also be managed or deleted from within the Pilot portal, please see this page for more information: https://indocconsortium.atlassian.net/wiki/spaces/JSDNXT/pages/4317708753
Please note, if the source or destination locations are altered (either renamed or removed) before running the resume upload command, resuming upload will fail and you will be prompted to re-start the upload utilizing the upload command.
$ pilotcli file resume --help
Usage: pilotcli file resume [OPTIONS]
Resume the upload process with given manifest file.
Options:
-td, --thread INTEGER The number of thread for upload a file
[default: 1]
-r, --resumable-manifest TEXT The manifest file for resumable upload
[required]
--help Show this message and exit.Examples
(1) Resume the upload with resumable upload file (resumable_upload_log.json)
The resumable command uses the manifest file generated from
file uploadto resume all uploadsCommand structure: pilotcli file resume -r <resumable manifest json file>
example: pilotcli file resume -r ~/Documents/resumable_upload_log.json
$ pilotcli file resume -r ./resumable_upload_log.json
Resume the upload for 10 files.
Resumable upload check complete.
Uploading aggregated.py: |ββββββββββββββββββββββββββββββ 100% 00:00
Uploading __init__.py: |ββββββββββββββββββββββββββββββ 100% 00:00
Uploading service_meta_class.py: |ββββββββββββββββββββββββββββββ 100% 00:00
Uploading upload_form.py: |ββββββββββββββββββββββββββββββ 100% 00:00
Uploading convert_type.py: |ββββββββββββββββββββββββββββββ 100% 00:00
Uploading singleton.py: |ββββββββββββββββββββββββββββββ 100% 00:00
Uploading __init__.py: |ββββββββββββββββββββββββββββββ 100% 00:00
Uploading base_library.zip: |ββββββββββββββββββββββββββββββ 100% 00:00 0% ?
Uploading EXE-00.toc: |ββββββββββββββββββββββββββββββ 100% 00:00
Uploading xref-pilotcli_test20230227_3.html: |ββββββββββββββββββββββββββββββ 100% 00:00
Upload Time: 11.13s for 10 files