How to download images and files of an entity

If my articles containing images, then this query:

{
  findArticles(published: {is: true}) {
    name
    creationDate
    content {
      secret
      md 
    }
  }
}

will provide the images as links, i.e.

![LinhRab.jpg](/api/files/6ceda0ff-a002-487f-be53-9f971e1c0230#width=1638&height=1638)

Beside searching for the string or parsing it into the AST, is there a way to get it right from the API?

If you’re talking about images that are embedded in the content of a rich text field, there is no API call that will get you the image directly

Not sure what you mean. I suppose what I need is just to get the image url (api/files/6ceda0ff-a002-487f-be53-9f971e1c0230) without having to fetch the content

But you’re talking about images that are in a rich text field, right? You’re not talking about files which have been attached to the entity via the Files field…?

yes you are right. I forget that the field is called “rich text”. Why doesn’t it have an API for that? Apparently it has the URL

Not sure what you mean. The contents of any rich text field is available via the API

My point is that there is no single dedicated API to find/retrieve files which are embedded in the rich text. You need to retrieve the rich text field contents and then use the file API to get the file itself.

1 Like