I have an audio file that is stored as Media of type Audio.

Now I want to get the link to that file that is usually displayed to site users via jsonapi.

For example, when the media entity is rendered, this is the link:

<audio controls="" controlslist="nodownload"> <source src="/sites/default/files/coolstuff/audio/apples-bananas-pears.mp3" type="audio/mpeg"> </audio>

This /sites/default/files/coolstuff/audio/apples-bananas-pears.mp3 path is what I want to get from jsonapi.

However, when I look at the output of /jsonapi/media/audio, all the URLs look like this:


None of them have the public-facing URI.

The documentation gives this example for a "article media entity reference field_image url, uri by including references":


I have media entity references, so I tried the same on my site:


However, I do not get the regular media URI, just the jsonapi one.

How can I get the media public file URI (/sites/default/files/coolstuff/audio/apples-bananas-pears.mp3)?


Here's the correct path:


This results in a value for uri such as:

"value": "public:/sites/default/files/coolstuff/audio/apples-bananas-pears.mp3",

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.