Create Folders and Upload Data
All actions for files and folders can be found in the SDK references:
Create new folder
The following script creates a new folder in the root directory of Files. Ensure that you:
- Replace <private_key_path> with the path to your private key.
- Replace <folder_name> with the name you want to give your folder. We recommend using unique folder names.
- Replace
A folder to store my files
with a meaningful description for your folder. - Replace
my: folder_metadata
with any metadata you want to add to the folder. Remove the line if you do not want to add any metadata to the folder.
Upload cloud data
The following scripts initiate uploads from your cloud storage to a specified folder in Encord. It works for all file types.
Upload is still in progress, try again later!
is returned, use the script to check the upload status to see whether the upload has finished. Ensure that you:
- Replace <private_key_path> with the path to your private key.
- Replace <integration_title> with the title of the integration you want to use.
- Replace <folder_name> with the folder name. The scripts assume that the specified folder name is unique.
- Replace
path/to/json/file.json
with the path to a JSON file specifying which cloud storage files should be uploaded. - If creating a new folder, replace
A folder to store my files
with a meaningful description for your folder. - If creating a new folder, replace
"my": "folder_metadata"
with any metadata you want to add to the folder.
To update client metadata, include the "upsert_metadata": true
flag in the upload JSON file. It can only be used in conjunction with "skip_duplicate_urls": true
.
Check cloud upload status
Use the following script to check the status of your private cloud upload.
Upload is still in progress, try again later!
is returned, run the script again to check the status at a later time. Ensure that you:
- Replace <upload_job_id> with the
upload_job_id
shown in the output of the script used to start the upload. In the example output of the script provided, theupload_job_id
=c4026edb-4fw2-40a0-8f05-a1af7f465727
. - Replace <private_key_path> with the path to your private key.
- Replace <folder_name> with the folder name. The scripts assume that the specified folder name is unique.
Upload local data to an existing folder
The following scripts add data to a folder that already exists in Files.
- Replace <folder_name> with the name of the folder you want to upload data to.
- For images and videos replace
User/path/to/my/file
with the path to your image or video file. - For DICOM series replace
User/path/to/dicom/file1
andUser/path/to/dicom/file2
with the paths to the DICOM files you want to create a series from. Add as many file paths as necessary. - For image groups and image sequences, replace
User/path/to/image/file1
andUser/path/to/image/file2
with the paths to the image files you want to create an image group or image sequence from. Add as many file paths as necessary.
Upload local data to a new folder
The following script creates a new folder in Files and uploads image, video, DICOM, image group, or image sequence files to the newly created folder. A new folder is created each time the script is run.
In the following scripts, ensure that you:
- Replace <private_key_path> with the path to your private key.
- Replace <folder_name> with the name you want to give your folder. The scripts assume that the specified folder name is unique.
- Replace
A folder to store my files
with a meaningful description for your folder. - Replace
my: folder_metadata
with any metadata you want to add to the folder. Remove the line if you do not want to add any metadata to the folder. - For images and videos replace
User/path/to/my/file
with the path to your image or video file. - For DICOM series replace
User/path/to/dicom/file1
andUser/path/to/dicom/file2
with the paths to the DICOM files you want to create a series from. Add as many file paths as necessary. - For image groups and image sequences, replace
User/path/to/image/file1
andUser/path/to/image/file2
with the paths to the image files you want to create an image group or image sequence from. Add as many file paths as necessary.
List data units in a folder
Listing the files in a folder can be used to verify that all data unit were successfully uploaded.
- Replace <private_key_path> with the path to your private key.
- Replace <folder_name> with the name you want to give your folder. The scripts assume that the specified folder name is unique.
Was this page helpful?