Skip to content

Attachments Download Bulk

Stevan Freeborn edited this page Apr 15, 2024 · 4 revisions

This command is intended to help Onspring customers download multiple attachments at once from one or more attachment/image fields from one or more records.

General Usage

When executing the command you will need to provide it with a Source Api Key and an App Id which the app will use to download the attachments contained within the app that corresponds to the given App Id.

These pieces of information need to be provided as command-line arguments.

onspringcli.exe attachments download bulk -sk 000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000 -a 100

Notes:

  • Source Api Key can be obtained as outlined in this repository's README.md API Key section.
  • App Id can be obtained...
    • by using the Onspring API's /Apps endpoint
    • by looking at the url of the app in your browser. i.e. https://instance.onspring.com/Admin/App/134

Options

This command currently has a number of options that can be passed as command-line arguments to alter the behavior of the command. These can be viewed by passing the -h or --help option to the command.

  • App Id: --app-id or -a
    • Allows you to specify an App Id to download attachments from.
    • Example usage: onspringcli.exe attachments download bulk -a 100
  • Output Directory: --output-directory or -o
    • Allows you to specify the name of the folder the attachments will be downloaded in.
    • Example usage: onspringcli.exe attachments download bulk -o downloads_folder
  • Fields Filter: --fields-filter or -ff
    • Allows you to specify what fields attachments will be downloaded from by providing a comma separated list of field ids.
    • Example usage: onspringcli.exe attachments download bulk -ff 1,2,3
  • Records Filter: --records-filter or -rf
    • Allows you to specify what records attachments will be downloaded from by providing a comma separated list of record ids.
    • Example usage: onspringcli.exe attachments download bulk -rf 1,2,3
  • Report Filter: --report-filter or -rpf
    • Allows you to specify an id for a report whose records' attachments will be downloaded.
    • Example usage: onspringcli.exe attachments download bulk -rpf 1

Note:

  • The filter options are additive to one another.
  • These are in addition to the Global Options detailed in this repository's README.md.

Output

Each time this command is executed it will generate a folder that is named according to the output directory name specified or if not specified it will be named by default output. All files generated by the command during the run will be written into this folder.

Example Output Folder Name:

output

Files

All files downloaded by the tool during the run will be saved into the output directory in a directory named files. Each attachment will be named according to the following format: RecordId-FieldId-FileId-FileName.

Example File Name:

1-11165-436-test-image.jpeg

Files List

In addition to the files downloaded the command will also produce a file-list.csv that will be written to the output directory. This file will contain a list of all the files downloaded and include the following information about each attachment downloaded:

  • Record Id: The id of the record that the attachment is attached to.
  • Field Id: The id of the field that the attachment is held in.
  • Field Name: The name of the field that the attachment is held in.
  • File Id: The id of the file.
  • File Name: The name of the file.
  • File Path: The path to the file on your local machine.

Error Report

If the app encounters any errors while executing the command and downloading the attachments it will write a file-request-errors.csv to the output directory that details the attachments that could not be downloaded. The file will contain the following information about each attachment that could not be downloaded:

  • Record Id: The id of the record that the attachment is attached to that could not be downloaded
  • Field Id: The id of the field that the attachment is held in that could not be downloaded
  • Field Name: The name of the field that the attachment is held in that could not be downloaded
  • File Id: The id of the attachment that could not be downloaded

Clone this wiki locally