getBlobURL

Uses the data handler getBlobURL of the data object to get a pathname for a file. Can be given either a primkey, field and file name as parameters, or a record with PrimKey and FileName fields and a field value.

If you give a record, and the record does not have both PrimKey and FileName fields, an empty string will be returned.

Usage

You can give a specific primary key and file name directly. In this example we have a data object with an Image blob field. The field doesn't need to be in the data object, but must exist in the view used by the data object.

function MyComponent({ record }) {
  return (
    <img
      src={dsMyDataObject.getBlobURL(
        record.PrimKey,
        "Image",
        `avatar-${record.ImageHash}.jpg`
      )}
      alt={record.FullName}
    />
  );
}

Alternatively, if the data object has both a field called PrimKey and a field called FileName, you can pass the record directly to the method:

function MyComponent({ record }) {
  return <img src={dsMyDataObject.getBlobURL(record, "Image"} alt={record.FullName} />
}

API

While there is a parameter to choose if you want to download or view the file, it currently does not affect the URL returned, as this is not implemented for blob file handlers

Last updated

Was this helpful?