We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20364
    • 89 Posts
    [Using Revolution]

    I am clearly missing something major here ...

    I am trying to simply create a resource that prompts the user to download a PDF when they hit it. It looked like Static Resource is what I want for this ...

    When I attach it to a PDF as the resource and select "Attachment" for Content Disposition and hit the page, Acrobat pops up and says
    File does not begin with ’%PDF’
    I figured I might need to create a new Content Type for PDF, which I did, but that gives the same error.

    Can someone give me some quick insight as to how this should work?
      • 22303 MODX Staff
      • 10,725 Posts
      You definitely have to create a Content Type for that in MODx. What details did you give the Content Type? And did you assign that Content Type to the Static Resource after creating it? We are serving PDF’s as static resources successfully from modxcms.com using application/pdf, though I think you don’t want attachment as the disposition since browsers typically use plugins to handle these content types.
        • 3749
        • 24,544 Posts
        Maybe I’m misunderstanding the question, but I’m pretty sure I’ve set up .PDF files for download just by using a Static Resource with the Content Type set to Attachment, template set to blank, and the path in the content field -- without creating a new content type. I think having the content type is what’s launching Acrobat.
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: BobRay at Jan 26, 2010, 09:23 PM

          Maybe I’m misunderstanding the question, but I’m pretty sure I’ve set up .PDF files for download just by using a Static Resource with the Content Type set to Attachment, template set to blank, and the path in the content field -- without creating a new content type. I think having the content type is what’s launching Acrobat.
          Attachment is the content disposition, not content type. If you got it to download it downloaded with the wrong content type header. Browsers are configured to automatically handle PDF files with Acrobat Reader plugins. The disposition may change that but I’m not sure; I think the client controls the action taken by content type (i.e. you’d have to configure the browser to download rather than open PDFs inline).
            • 3749
            • 24,544 Posts
            Quote from: OpenGeek at Jan 27, 2010, 01:13 PM

            Quote from: BobRay at Jan 26, 2010, 09:23 PM

            Maybe I’m misunderstanding the question, but I’m pretty sure I’ve set up .PDF files for download just by using a Static Resource with the Content Type set to Attachment, template set to blank, and the path in the content field -- without creating a new content type. I think having the content type is what’s launching Acrobat.
            Attachment is the content disposition, not content type. If you got it to download it downloaded with the wrong content type header. Browsers are configured to automatically handle PDF files with Acrobat Reader plugins. The disposition may change that but I’m not sure; I think the client controls the action taken by content type (i.e. you’d have to configure the browser to download rather than open PDFs inline).

            Right, I meant to say content disposition. I know there’s no way to "force" a download, but IIRC, by changing the disposition I got it to download in some browsers and give a choice between opening it and saving it in others. I’m also pretty sure I opened it with Acrobat after the download and was able to see the content with no trouble.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              It depends on the browser settings. Different browsers (even different versions of the same browser) have different default settings, and in many cases a browser’s global security settings will affect how various files are handled.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 21635
                • 81 Posts
                i also try to provide downloadable/clickable PDFs through static resources and seem to hit a wall.
                can’t figure out what could be wrong...

                i create a content type "PDF":
                MIME: application/pdf
                ext: .pdf
                binary: yes

                after uploading the pdfs to the file system i reference them via the modx-browser.
                content-type: pdf
                content-disposition: inline

                then my safari-console tells me

                Ressource wurde als Dokument interpretiert, aber mit MIME-Typ application/pdf übertragen.

                which is german and means:
                "interpreted resource as document, but received MIME-type application/pdf..

                any hints? i going in circles...

                thanks!
                  • 22303 MODX Staff
                  • 10,725 Posts
                    • 18654
                    • 191 Posts
                    I have a related question that was discussed in this thread. The issue was that binary content (i.e. mp3’s) would not download when a template was assigned to the Static Resource. OpenGeek’s response at the time was:

                    Templates are not recommended for binary content types

                    My question is: Is this by design? Is it a bug? Should it be a feature request? Has it already been fixed since the last time the issue was brought up?

                    I’m trying to figure out if we will we ever be able to use templates and TV’s for binary Static Resource’s. I think this is an important functionality to have available for any situation where one wants to list downloads with additional data associated with them (i.e. IsFree||RegisterToDownload).


                      God does not save those who are only imaginary sinners. Be a sinner, and let your sins be strong, but let your trust in Christ be stronger, and rejoice in Christ who is the victor over sin, death, and the world.
                      • 21635
                      • 81 Posts
                      I think this is an important functionality to have available for any situation where one wants to list downloads with additional data associated with them (i.e. IsFree||RegisterToDownload).

                      Absolutely, this is what i wanted to accomplish. List a category of StaticResources using the getResources-Snippet. Then in the listing show a corresponding thumbnail, a description and (of course) a working download-link.

                      Any tips how to accomplish that in another way?