Code snippet
Check whether File column contains data
Copy it with the button on the code. For the why and the walkthrough, see “How to retrieve File columns using Power Pages’ Portal Web API”.
{% assign track_record = entities['musdyn_track'][request.params.id] %}
{% if track_record.musdyn_audiotrack_name %}
<script>
webapi.safeAjax({
type: "GET",
url: "/_api/musdyn_tracks({{ request.params.id }})/musdyn_audiotrack",
contentType:"application/json",
success: function(res) {
console.log(res);
$('#main').append('<audio controls><source src="data:audio/mp3;base64,' + res.value + '" type="audio/mpeg">Your browser does not support the audio element.</audio>')
},
error: function(xhr, status, error){
var errorMessage = xhr.status + ': ' + xhr.statusText;
console.log(errorMessage);
}
});
</script>
{% endif %}