Uploading images in 2 way sync tables

I’m trying to establish 2 way sync for a table that contains images. I can set the column to be an image in Coda, but when I add an image to the table and then try to “Send Edits” the only thing that gets sent to the pack is the name of the image file.

Is it possible to send the public_url and other metadata like the alt_text, or maybe just the public URL instead of the file name to the pack?

cc @Eric_Koleda

Hi @Josh_Shupack1 - What is the type of the schema property as you define it in your Pack? If you define it as a String and change it to an Image column in the doc then I think the Pack will get the ToText() value of the image, which is the file name. If you define it as ImageAttachment (or better an array of them) then you’ll get an Image column automatically and your code will get the URLs as expected.

Here’s some rough sample code showing two-way editable image columns:

import * as coda from "@codahq/packs-sdk";
export const pack = coda.newPack();

const ThingSchema = coda.makeObjectSchema({
  properties: {
    name: { type: coda.ValueType.String },
    id: { type: coda.ValueType.String },
    image: { 
      type: coda.ValueType.String, 
      codaType: coda.ValueHintType.ImageAttachment,
      mutable: true,
    },
    images: {
      type: coda.ValueType.Array,
      items: { 
        type: coda.ValueType.String, 
        codaType: coda.ValueHintType.ImageAttachment,
      },
      mutable: true,
    },
  },
  displayProperty: "name",
  idProperty: "id",
  featuredProperties: [
    "image", "images"
  ],
});

pack.addSyncTable({
  name: "MyThings",
  description: "Table description.",
  identityName: "Thing",
  schema: ThingSchema,
  formula: {
    name: "SyncMyThings",
    description: "Syncs the data.",
    parameters: [],
    execute: async function (args, context) {
      let rows = [
        {
          id: "1",
          name: "One",
          image: "https://images.dog.ceo/breeds/terrier-russell/little1.jpg",
          images: ["https://images.dog.ceo/breeds/terrier-russell/little1.jpg"],
        },
      ];
      return {
        result: rows,
      };
    },
    executeUpdate: async function (args, updates, context) {
      let row = updates[0].newValue;
      console.log(row);
      return {
        result: [row],
      };
    },
  },
});