Skip to content

Files & Images

Upload files and images from an HTML Page. The returned data is used to populate a file or image column — typically by passing it into updateRow or addRow (see Rows). The sdk instance below is created and initialized as shown in Initialization.

Return value

Unlike the row methods, the upload methods resolve to the result object directly — there is no .data wrapper.

uploadFile

Upload a file for use in a file column.

sdk.uploadFile({ file });

Parameters

file
object — the file to upload (for example, a File from an <input type="file">)

Returns { name, size, type, url } — pass this object as the value of a file column.

Example

fileInput.addEventListener("change", async (e) => {
  const file = e.target.files[0];
  const { name, size, type, url } = await sdk.uploadFile({ file });

  await sdk.updateRow({
    tableName: "Documents",
    rowId: "fcHIocncTsOygA3FjL-toQ",
    rowData: { Attachment: [{ name, size, type, url }] },
  });
});

uploadImage

Upload an image for use in an image column.

sdk.uploadImage({ file });

Parameters

file
object — the image file to upload

Returns { name, size, type, url } — same shape as uploadFile, with type set to "image". Pass the URL as the value of an image column.

Example

fileInput.addEventListener("change", async (e) => {
  const file = e.target.files[0];
  const { url } = await sdk.uploadImage({ file });

  await sdk.updateRow({
    tableName: "Products",
    rowId: "fcHIocncTsOygA3FjL-toQ",
    rowData: { Photo: [url] },
  });
});