Skip to main content
All CollectionsAdvanced Topics
Image Import Background Job
Image Import Background Job

This article describes a background job which can pull images from a remote URL, store them in MetaLocator and update the local image field

Michael Fatica avatar
Written by Michael Fatica
Updated over 3 weeks ago

Occasionally our customers provide Image URLs that are not appropriate for serving content on the Web. They may be private or from a CRM that does not support hot-linking. For this use case, MetaLocator can download the images provided in the customer data and update another field with a new URL with a local copy of the image, hosted on MetaLocator's fast CDN.

This requires configuration of the Pull Images background job.

This background job handles the bulk import of images, allowing for efficient processing of data from a remote URL to a locally stored, publicly accessible URL ready for serving on the Web. The job is highly configurable through the use of arguments, enabling customization of the source and destination tables, image field, batch size, refresh interval, and additional HTTP headers.

Configuring the Pull Images Job

  1. Create a new Job under Background Jobs.
    ​

  2. Choose PullImages as the job type

  3. Provide a Job Name

  4. Provide The following required arguments as shown below:

    1. source_field

    2. destination_field

  5. Save, publish and schedule the job.

Arguments

The background job accepts the following arguments:
​

1. source_table

  • Description: Specifies the name of the database table from which the source data will be pulled.

  • Default Value: 'locations'

  • Usage: If no value is provided, the default locations table will be used.


2. destination_table

  • Description: Specifies the name of the database table where the images will be imported.

  • Default Value: 'locations'

  • Usage: If no value is provided, the default locations table will be used.


3. source_field

  • Description: Specifies the field in the source table that contains the image data or URLs.

  • Default Value: 'image'

  • Usage: If no value is provided, the default image field will be used.


3. destination_field

  • Description: Specifies the field in the destination table that should receive the updated image URLs.

  • Default Value: None (this value is required)

  • Usage: If no value is provided, the default image field will be used.


4. header1, header2, header3

  • Description: Optional HTTP headers that can be included in the import process (e.g., for API calls or file requests).

  • Default Value: None (headers are optional).

  • Usage:

    • If any of these headers are provided, they will be added to the request.

    • Examples:

      Authorization: Bearer token
      Content-Type: application/json

5. refresh

  • Description: If set to 1, re-downloads any images that are already set in the destination_field. If 0, the job will skip any rows for which a value in destination_field has already been provided..

  • Default Value: 0 (no refresh).

  • Type: Integer


6. batchsize

  • Description: Specifies the number of records to process in each batch during the import operation.

  • Default Value: None (must be explicitly defined).

  • Type: Integer

7. erase_empty

  • Description: If 1, specifies that the destination field should be emptied where the source field is empty. This removes values from the destination field and should be used with caution. Use this option in order to maintain synchronization with values that have been removed from the source_field.

  • Default Value: 0

  • Type: Integer

Did this answer your question?