[βœ… Solution] Automation: Load Image From URL and Save it

I try to load an image from an external URL and then save it in a image field of the same entry.

How would you do that?

1 Like

Hi @Roman,

thanks for your post - and welcome!

Let me get back to you with a working example asap, will share it here once I have it available.

Cheers & have a great day
Tim

1 Like

Hi @Roman,

excuse the delay - we had to deploy a little update fix to Tape this evening, that makes this even smoother for you.

Here’s the drill - use a simple execute script action inside a workflow to

  1. download the external image via the URL
  2. upload the file to the Tape API to get a file reference
  3. attach the file to the current record.

The script to use would look similar to this one:

// download your image via the external URL
const url = image_field_via_url_field_url_value;
const { data: file_content } = await http.get(url, {responseEncoding: 'binary'});

// upload the downloaded image to Tape
const encoded_file_content = Buffer.from(file_content, 'binary');
const { data: uploaded_file } = await tape.File.upload({filename: 'image.png', source: encoded_file_content});

// update current record using the uploaded file reference
const uploaded_image_file_id = uploaded_file.file_id;
await tape.Record.update(current_record_id, {fields: {image:uploaded_image_file_id }})

This script assumes that image_field_via_url_field_url_value holds your external image URL. You can replace it with your field variable name, or use a static image URL for testing. Also, ensure that in the last line you provide the proper external ID of your image field, in my case it is simply image.
Usually, it corresponds to the field name in lowercase, but you can look it up in the developer section of the app:

Ultimately, the workflow may look similar to this:

Just tested this and it works like a charm and adds external images to my record quickly and reliably:

Let me know if that works for you!

Happy building & Cheers
Tim

1 Like