How to add assets to custom Handlebars Components
This guide describes the two supported methods (manual or GraphQL) for adding additional assets, including images, to a specific component.
Add an image file manually
To manually add a picture for usage in a component, place the image file in the assets subfolder of the component's directory.
For our example, we have added the image file named badge.png to the components/TopMembers/assets directory.
Add an image file for a component via GraphQL
To upload an image file (or any type of asset) via GraphQL, use the saveComponentTemplateAssetFromUpload
mutation. This mutation should be made as a multipart/form-data request with a file.
Here is an example cURL script that uploads an image file.
curl --location 'http://community.mine.com/t5/s/api/2.1/graphql' \
--header 'Authorization: Bearer r8iuFP51VSVMkBztKC7dqy40hFQQF66hV+pGotPHG8U=;' \
--header 'Content-Type: multipart/form-data' \
--form 'operations="{ \"query\": \"mutation($templateId: String!, $assetId: String!, $assetPart: Upload!) { saveComponentTemplateAssetFromUpload(templateId:$templateId assetId:$assetId assetPart: $assetPart){result {name directoryName subDirectoryName feature size lastModified revision mimeType url } errors {...on Error { message fields }}}}\", \"variables\": {\"templateId\": \"TopMembers\", \"assetId\": \"khorosIcon\", \"assetPart\": null} }"' \
--form 'map="{\"file\":[\"variables.assetPart\"]}"' \
--form 'file=@"badge.png"'
ATLAS
Comments