New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open pdf file on browser #212

Closed
khanhtranchi opened this Issue May 24, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@khanhtranchi
Copy link

khanhtranchi commented May 24, 2018

Hi all,

I want to open a pdf file on browser like this link https://www.bestessays.com/samples/term_paper.pdf.
But I can not do that with pdf files that are uploaded through the document management in cms.
Could you guide me how to do that? I refer to this topic https://github.com/cofoundry-cms/cofoundry/wiki/Documents, but can not find the way to do.

Thanks.

@HeyJoel

This comment has been minimized.

Copy link
Member

HeyJoel commented May 24, 2018

Do you mean in the way it opens in the browser windows rather than forcing a download?

I'll need to take a look into that, but as a workaround you can make your own file controller and modify it however you wish by using the eixsting File route in the CofoundryAssetsController as an example.

@HeyJoel HeyJoel added the bug label May 24, 2018

@HeyJoel HeyJoel added this to the 0.3.2 milestone May 24, 2018

@khanhtranchi

This comment has been minimized.

Copy link

khanhtranchi commented May 25, 2018

Hi @HeyJoel ,

Do you mean in the way it opens in the browser windows rather than forcing a download?
--> Yes, I want to open pdf file in the browser window rather than download and open it with the pdf reader.

If I upload file to wwwroot folder, I can open it on the browser window directly. I guess maybe the response header's controller need to clarify a little bit when returns FileResult like this post mention https://stackoverflow.com/questions/6293893/how-do-i-force-files-to-open-in-the-browser-instead-of-downloading-pdf

@HeyJoel

This comment has been minimized.

Copy link
Member

HeyJoel commented May 25, 2018

Ok so it seems the Content-Disposition is set to attachment rather than inline. I'll have to do a bit of investigation as to what the correct default behaviour should be here with various file types, and whether we should provide an alternate route or mehod of generating links for inline display.

I suspect the best default will be removing the content-disposition altogether which will use the default inline, which is what the example term paper does. We can then provide an alternate route for download (content-disposition: attachment) or the developer can use the anchor download attribute to control this from the view.

HeyJoel added a commit that referenced this issue Jun 7, 2018

Fixes #212 - Open pdf file on browser
* Default document file content disposition changed from "attachment" to "inline"
* Added extra url "DocumentDownload" routes to the content/docuemnt route libraries to allow for forcing download of a document.
* Added "download mode" to document block type
* Fixed formatting of enum DDL text display for pascal case properties
@HeyJoel

This comment has been minimized.

Copy link
Member

HeyJoel commented Jun 7, 2018

I've fixed the document download to use the expected default "inline" content disposition and added alternate routes to the IDocumentAssetRouteLibrary and IContentRouteLibrary that generate links that force a download using the old behaviour (with content disposition "attachment").

The document block type has also been updated to allow users to choose whether to have the document display inline or force a download.

This will be released in v0.3.2

@HeyJoel HeyJoel closed this Jun 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment