Main Content

Magnolia Community Forums: Development: Deep Link to asset


  • proland
    proland
    Full name: Philipp Roland
    Posts: 12
    Last post: Apr 10, 2017 10:59:28 AM
    Deep Link to asset
    #1 by proland on Oct 27, 2016 10:37:46 AM

    Hi

    I guess it's a very stupid question, but I struggle around since a long time and problably you got an easy solution:

    How can I access a PDF-Document, that is stored in Magnolia. It is not stored in the "normal" DAM but in a custom repository/workspace.

    What I try to do is: I want to embed this in a ftl like this "<embed src="http://localhost:8080/blablabla/mypdf.pdf" width="100%" height="400px" />". What I need for that is the appropriate deep-link.

    Any help is very appreciate.

    Thanks
    Roland

  • tomwespi
    tomwespi
    Full name: Tom Wespi
    Posts: 34
    Last post: Nov 9, 2016 12:15:55 PM
    Re: Deep Link to asset
    #2 by tomwespi on Oct 27, 2016 11:04:46 AM

    Hi

    [#assign link = cmsfn.link("workspace", content.pdf)]

    where content.pdf is the uuid to the pdf.

    Don't forget to add the «URI2RepositoryMapping» to your workspace in Config/Server/mappings

    HTH

    Tom

  • cmeier
    cmeier
    Full name: Christoph Meier
    Posts: 195
    Last post: Apr 18, 2017 5:34:26 AM
    Re: Deep Link to asset
    #3 by cmeier on Oct 27, 2016 11:10:39 AM

    Hi Philipp

    I think it would be (much) easier to use DAM app and store the PDF as an asset.


    I just have seen the post from Tom.
    I'm really curious whether it works :-)


    This would have been my answer before i have seen Toms solution:

    When it comes to images, it is kind of easy to have them on any workspace and to create links to the images. See
    - https://documentation.magnolia-cms.com/display/DOCS/Working+with+images
    - https://documentation.magnolia-cms.com/display/DOCS/Working+with+images+using+imgfn

    But this is not applicable 1:1 to PDFs.
    The reason is, that the ImagingServlet knows how to resolve the path / link of an image and how to respond appropriate.

    For a PDF, the DamDownloadServlet would know how to correctly respond for an asset which is a PDF (concerning correct response-type, etc. pp). So, for an out-of-the-box solution, it looks like you have to use DAM and store the PDF as an asset.

    For a custome solution handling PDFs stored in another workspace, you may have to write your own servlet, for this DamDownloadServlet may inspire you.

    If you already havea bunch of content storing PDF binary data in aother workspace, it may be quicker to migrate content with a groovy script instead of writing custom Servlet etc.


    I hope this helps, maybe somebody else has a better idea :-)
    cheers,
    Christoph

  • proland
    proland
    Full name: Philipp Roland
    Posts: 12
    Last post: Apr 10, 2017 10:59:28 AM
    Re: Deep Link to asset
    #4 by proland on Oct 27, 2016 11:55:39 AM

    Hi

    First: Thanks a lot for your suggestions!!!!!!!!

    I've tried Toms solution and I've really get back a URL (/connect-hearing-webapp/connect-hearing/maps-assets/gateB/Hotfix-FirstRepublic-3449.pdf/jcr:content/Magnolia%20Flyer%204.0.pdf.pdf). But this URL doesn't point me to the pdf (I've got an Magnolia Ooops-page, of course I preset the "localhost:8080" to the URL.

    What I've done so far, is that I create the URI2RepositoryMapping-Entry by duplicating the "dam"-Entry and only change the "URIPrefix" and "Repository" to my Repository (the class is the same as on DAM right?).

    Any ideas what I've done wrong?

    Thanks in advance,
    Roland

  • tomwespi
    tomwespi
    Full name: Tom Wespi
    Posts: 34
    Last post: Nov 9, 2016 12:15:55 PM
    Re: Deep Link to asset
    #5 by tomwespi on Oct 27, 2016 6:50:32 PM

    Hi

    I don't think you need the class «info.magnolia.dam.core.link.DamURI2RepositoryMapping».

    It should look like this
    URIPrefix /myWorkspace
    handlePrefix
    repository myWorkspace

    Out of curiosity: Does the the link «/connect-hearing-webapp/connect-hearing/maps-assets/gateB/Hotfix-FirstRepublic-3449.pdf» work?

    And I assume you use the Magnolia Version 5.4.9

  • proland
    proland
    Full name: Philipp Roland
    Posts: 12
    Last post: Apr 10, 2017 10:59:28 AM
    Re: Deep Link to asset
    #6 by proland on Oct 27, 2016 7:37:18 PM

    Once again thanks for your reply.

    No the link "/connect-hearing-webapp/connect-hearing/maps-assets/gateB/Hotfix-FirstRepublic-3449.pdf does not work either.

    And in this project we are using Magnolia 5.3.12.

    Thanks
    Roland

  • tomwespi
    tomwespi
    Full name: Tom Wespi
    Posts: 34
    Last post: Nov 9, 2016 12:15:55 PM
    Re: Deep Link to asset
    #7 by tomwespi on Oct 27, 2016 7:59:13 PM

    Did you remove the class from the URI2RepositoryMapping?

    And then please try again with the cmsfn.link

  • proland
    proland
    Full name: Philipp Roland
    Posts: 12
    Last post: Apr 10, 2017 10:59:28 AM
    Re: Deep Link to asset
    #8 by proland on Oct 28, 2016 10:28:18 AM

    Thank you Tom for your input!!!

    I've now removed the "class" from URI2Repository. So now there are only the following entries for the "maps-assets"-node of "URI2RepositoryMapping":

    URIPrevix /maps-assets/
    handlePrefix -
    repository maps-assets

    With the "cmsf.link" now I get back the URL "/connect-hearing-webapp/connect-hearing/maps-assets/gateB/Magnolia-Flyer-4.0.pdf.html". So new there is a ".html" added at the end. But this still gives me a "404" if I enter this URL in a separate Tab of my browser (of course with preset "localhost:8080").

    Any other ideas?

    Thanks
    Roland

  • rgange
    rgange
    Full name: Richard Gange
    Posts: 44
    Last post: Dec 13, 2016 8:35:33 AM
    Re: Deep Link to asset
    #9 by rgange on Oct 28, 2016 3:02:07 PM

    Hey Guys-

    I think the reason this doesn't work is because you need a special servlet for delivering pdf files. The repository mapping is only half the battle. See https://documentation.magnolia-cms.com/display/DOCS53/DAM+core+functionality. At the bottom of that page we show the mapping and the servlet. Without the servlet you'll hit rendering which won't know what to do with this request.

    HTH
    richg

  • proland
    proland
    Full name: Philipp Roland
    Posts: 12
    Last post: Apr 10, 2017 10:59:28 AM
    Re: Deep Link to asset
    #10 by proland on Oct 31, 2016 8:25:57 PM

    Hi

    I've solved it by creating a copy-servlet of the DamDownloadServlet. In this servlet I seek for the uuid of the asset in our custom-workspace. This works for us.

    Thanks again to everybody for your appreciated suggestions.

    Regards
    Roland

You don't have the permission to post on this thread

Sign in

To login on this forum, you can use your Magnolia Forge, Support or Partner account, or, below, your Google, Yahoo! or OpenID account. If you have trouble logging in, or any other sort of issue, please let us know in the Meta forum, on the user-list, or simply by email at forum-admin at magnolia-cms dot com.

* Required

... or sign in with:

  • icon http://{your-openid-url}
  • icon
  • icon https://me.yahoo.com/