Create Salesforce Attachment

Hi everyone,

How can I go about creating an Attachment record in Salesforce from a provided file using the “File Upload” component? That SF object has an BODY property that wants binary data.

My first attempt was to:

  1. Add a File Upload component
  2. Use the Download Encoded Asset operation to get the binary
  3. Create the Attachment record via another data operation

I’m getting “invalid object type” for #2 when attempting to pass in the asset. Also I realize the Download Encoded Asset has a limit of 1mb which may be an issue.

What’s the best way to do this (maybe not using the Download Encoded Asset operation at all)? And is there a way that would get past the 1mb limitation?

Hi @blschaef15 what exactly are you passing into the download encoded asset data operation?

the Download encoded asset can accept either an asset URI:

asset://global:{asset-id}

Or an asset object (something that looks like this)

{
  "id": "",
  "hash": "",
  "size": 2898,
  "type": "image/png",
  "scope": "SESSION",
  "state": "ACTIVE",
  "region": "us-west-2",
  "version": 0,
  "assetKey": "",
  "hashType": "SHA256",
  "extraInfo": null,
  "expiration": 3600000,
  "visibility": "GLOBAL",
  "createdTime": "2022-06-13T18:14:35.005Z",
  "deletedTime": null,
  "description": null,
  "displayName": "0 (3).png",
  "downloadUrl": "",
  "modifiedTime": "2022-06-13T18:14:36.638Z",
  "storageClass": "v1",
  "thumbnailUrl": "",
  "organizationId": "",
  "validationErrors": null
}

In the screenshot below, i’m passing an asset object to the Download encoded asset data operation and am able to get an encoded asset:


Also, here’s a video of me walking through a simple file upload scenario to Salesforce.

1 Like