assets
For use with Netlify Visual Editor only.
connector.assets(opts)
Used to define how to manage assets stored on your data source.
Takes an object where the key is a function defined by your connector. The object contains the following property:
Parameter | Description |
---|---|
create | Used to upload an asset to your data source. |
Get assets with connector.sync()
With the SDK, you don’t need to define separate logic using connector.assets
to get assets from your data source. Instead, you can get assets during data syncs.
create
Receives a function to be used when uploading assets to your data source. The function is passed an object as the first parameter with the following properties:
Property | Description |
---|---|
base64 | (optional) String containing a base64 representation of the asset (provided when working locally using stackbit dev ). |
fileName | String representing the asset’s filename. |
locale | (optional) String representing the locale ID for the asset. |
mimeType | String representing the MIME type of the asset. |
state | Object containing data stored in initState when addConnector runs. |
url | (optional) String representing the temporary URL that contains the asset. |
userContext | (optional) UserContext . An object that contains the user’s email, name, and optional OAuth access tokens defined by the UserContext generic type. |
Your function should use the accessToken
in userContext
to verify and ensure that all changes in the data source are made on behalf of the user. Changes should not use a general management token that is used to read content.