[SOLVED] Upload pdf in backend and access url in frontend

I have a property which looks like:

  'pdfUpload':
    type: 'Neos\Media\Domain\Model\Asset'
    ui:
      label: i18n
      inspector:
        group: 'upload'

How to access to the url of the given file in the frontend? The docs only contain MediaHelper for images and thumbnails. https://neos.readthedocs.io/en/stable/References/ViewHelpers/Media.html

For use in PHP, see Persistent Resources in the Accessing Resources section of the documentation.

In case you need this in Fusion, see Neos.Fusion:ResourceUri.

For Fluid, you were close, I think. See f:uri.resource

1 Like

Thanks for the reply.

I just tried but didnt get it work out. Can u provide a working example?

<f:if condition="{pdfUpload}">
	<f:debug>{pdfUpload}</f:debug>
</f:if>

Result:

Neos\Flow\Persistence\Doctrine\Proxies\__CG__\Neos\Media\Domain\Model\Documentpersistableproxy

I tried but didnt work out:

{f:uri.resource(ressource : pdfUpload)}

Did you really try two s? It should be {f:uri.resource(resource : pdfUpload)}

Yes you are right. My bad.

But unfortunately there was another mistake. As you can see here in the Persistent resource object example, you have to append .resource to the property.

https://neos.readthedocs.io/en/stable/References/ViewHelpers/FluidAdaptor.html#id66

The working result ends up in:
{f:uri.resource(resource : pdfUpload.resource)}

Thanks a lot. I appreciate your help.