ExportFiles Core Add-On Module.


This module allows you to transfer the salesforce File objects (ContentVersion, ContentDocument, ContentDocumentLink) including the binary data with the sObject records.

Table of Contents



Minimal ExportFiles module setup.

In order to transfer Salesforce Files by using the ExportFiles Core Add-On Module, you should simply declare the module call in your export.json.

This small setup will assist you to Upsert the Account records and then to Insert the salesforce Files, attached to these Account records.

The Files will be automatically linked to the proper records on the Target side:

 "objects": [
     {
         "operation": "Upsert",
         "externalId": "Name",
         "query": "SELECT Name FROM Account",

         "afterAddons" : [
             {
                 "module": "core:ExportFiles",
                 "args" : {
                     "operation" : "Insert"
                 }
             }
         ]

     }
 ]

"afterAddons" - it's the OnAfter Add-On event declaration (in Object's scope) where this module should be triggered, see the list of supported Add-On events.

We want to trigger it AFTER the Account records were fully processed.

Full ExportFiles module setup.

Find below the full list of the args properties relevant to the core:ExportFiles module.

To use all the defaults you can omit the args parameter from the module declaration.

Args Parameter Is Mandatory Data Type Description Default Value Sample Value
deleteOldData No boolean true to delete the old target Files before uploading new false true
operation No Insert / Upsert / Delete / Update Which operation to perform on the Files.

➦ It can be different from the operation applied to the parent object.
Same as the parent object Update
externalId No string Which field of the ContentVersion object to use to compare the source and the target content versions to determine whether the source version has changed or does not exist in the Target and so it should be uploaded.

➦ This is similar to the externalId property of the Script Object.
Title Description
sourceWhere No string The extra WHERE clause to process a limited subset of the source ContentVersion records.

➦ The Add-On always adds 'AND IsLatest = true' to retrieve only the last ContentVersion.
undefined Title ='sample-image'
targetWhere No string The extra WHERE clause to process a limited subset of the target ContentVersion records. The Add-On always adds 'AND IsLatest = true' to retrieve only the last ContentVersion.

➦ Typically the Add-On retrieves the target records only when need to compare the source and the target.
➦ In other hand, it is not performed for example for the Insert operation where the Target records does not matter.
undefined Title LIKE 'sample-%'
maxChunkSize No number For faster transferring of binary data, the ContentVersions are splitted into multiple chunks, each one is limited to maxChunkSize (in Bytes). The chunks are uploaded to the Target sequentially in multiple threads.

➦ This value should be less or equal to 38797312 bytes (37Mb). This ensures safe upload via the Salesforce API.
15728640 (15Mb) 20000000
maxFileSize No number This parameter controls the maximal ContentSize of file (in Bytes). Files which are greater are ignored and do not transferred.

➦ This value should be less or equal to 38797312 bytes (37Mb). This ensures safe upload via the Salesforce API.
38797312 (37Mb) 20000000
Notes:
  • The Add-On only works with Files linked to the parent object's records, which records were already uploaded to the Target org.

  • Export of Files into CSV file or import them from CSV file are NOT supported.

    • Upsert: will insert the new Files and update those which were changed in the Source org. The files are compared by the defined External ID field.
    • Update: will selectively update the changed Files, but will not transfer the new Files.
    • Insert: will insert all Files regardless whether they do exist or not in the Target.
    • Delete: will only delete the target files. You can limit amount of deleted files by using targetWhere property.
    • The Readonly operation is NOT supported for the Files.
  • The extermalId property belongs to the ContentVersion object. The default externalId is Title.

    • The Add-On splits high volume of the input Files into smaller chunks to reduce the memory usage.
    • In addition it downloads the binary content in parallel threading mode using throttler to upgrade the download speed remaining control over the amount of downloads running in parallel.
  • The maxChunkSize parameter does not split ContentVersion binary data. Each File binary is uploaded at once. The meaning of "chunk" is a multiple ContentVersions organized as a bundle, which is sent to the SF server at a single transaction. It is always recommended to avoid uploading large files in order not to run into problems of various system limitations (see the documentaiton).

See also Supported Add-On Api Events

Last updated on 13th Apr 2024