Hi, I have deployed one image on cumulocity binary. I want to get that image based on name. What I tried, I used custom query filter and tried to filter my image with this url but it is still returning all the binaries.
<tenant_url>/inventory/binaries?withTotalPages=true&pageSize=2000&query=$filter=name eq 'Aggregation service flow.png'
However the meta information for the binaries are stored as inventory managed objects (marked with the c8y_IsBinary fragment) so you can do an inventory query first to find the correct binary id, then retrieve the binary using the id.
For example, filter for managed objects with the c8y_IsBinary fragment, and the name matching Aggregation service flow.png.
GET /inventory/managedObjects?query=$filter=has(c8y_IsBinary) and name eq 'Aggregation service flow.png'
The REST API above will return all the matching binary meta information managed objects, so select the appropriate .id property.
Using the binary id found in the previous step, get the binary file using the binary API:
GET /inventory/binaries/{id}
If you’re a go-c8y-cli user, you could do the same lookup using the following chained commands (which does exactly the same as above, but using shell pipeline):
c8y inventory find --query "has(c8y_IsBinary) and name eq 'Aggregation service flow.png'" | c8y binaries get
Thank you for the response. It is working as expected, but I have one doubt. How Can I fetch this image or the doc whatever I have stored in binary in my code through rest API. I will get the response in postman but how can i fetch it in my code.
Lets say If I have stored 1 image and 1 doc, and I get the ids and i am trying to fetch it from binary, what object or what type will be returned by cumulocity in this case?