GraphQL request to get a link to a binary resource
A specific GraphQL request can return you a public URL pointing to a binary resource.
The following GraphQL request returns one or more nodes containing URLs to binary resources:
{
binaryComponent(publicationId: PUBID, namespaceId: NSID, binaryId: BINID) {
variants {
edges {
node {
binaryId
variantId
downloadUrl
path
type
}
}
}
}
}
where:
- PUBID is your publication identifier (a number)
- NSID is your namespace identifier (a number)
- BINID is the identifier of your binary resource (a number)
For example:
{
binaryComponent(publicationId: 40248, namespaceId: 1, binaryId: 7444) {
variants {
edges {
node {
binaryId
variantId
downloadUrl
path
type
}
}
}
}
}
If the binary resource has only one variant, the default variant, the response might look like this:
{
"data": {
"binaryComponent": {
"variants": {
"edges": [
{
"node": {
"binaryId": 7444,
"variantId": "[#def#]"
"downloadURL": "http://contentservice.tridion.com:8081/cd/api/binary/1/40248/7444",
"path": "40248-7444-16.gif",
"type": "image/gif"
}
}
]
}
}
}
}
If the binary resource has multiple variants, the edges array will contain multiple nodes, one for each variant.