How to prevent files from opening without downloading?

Nextcloud version (eg, 12.0.2): 18.0.0
Operating system and version (eg, Ubuntu 17.04): Ubuntu 18.04
Apache or nginx version (eg, Apache 2.4.25): nginx/1.14.0 (Ubuntu)
PHP version (eg, 7.1): 7.2

The issue you are facing:

When I click files in list, the downloading is started.
ex) .exe .zip

But specific files open without being downloaded.
ex) .py .pdf

I can download that files by click ‘…’ and click ‘download’ but I want to download every files without opening.
ex) pdf viewer

Is there any way to do that?

1 Like

I think the way it works, that you associate certain file extensions with apps. For some formats, you have corresponding extensions but what do you want to do with a .exe file?

I understand what @tflidd means is that the standard behavior depends on local settings of browser and OS. However, I support @hobang6’s request to make the behavior configurable although I must admit that I do not see how this should be done.
My use case is that I have a folder with .py-files that I would like to share with others. Experience shows that the expected behavior from a users’ point of view is to simply download a file upon clicking its link. It would be great if there was a way to fulfill these expectations. Otherwise the below-average user is stuck making personal intervention necessary which is precisely not the point of a public shared folder.
Greetings!

I think it is not only the browser function.

To deactivate “pdf showing in the browser” you can deactivate the app “pdf viewer”

https://apps.nextcloud.com/apps/files_pdfviewer

You are right about the PDFs, @devnull. I did some more testing and see the following behavior:

  1. .txt-files are offered for download
  2. .pdf-files are shown in browser or offered for download according to PDF-viewer being activated or not
  3. .py-files are opened for a preview which fails (!), i.e. it does not show anything at all.

The last point is remarkable. I seem to remember a time when previews actually did work for .py-files and the download could be triggered from the preview page. I am using almost the exact same set-up as the original poster, except that it is version 18.0.3. Can anybody confirm that previews did work on .py-files or even still do in some settings?

I think the preview and editing from text-files (equal suffix) is very bad in nextcloud.
Perhaps someone can include an editor like https://ace.c9.io (ok perhaps another editor with other licence)

Thanks for the pointer to the text editor issue, @devnull! As a work-around, I deactivated the Text app and now the download if offered.
To me it seems that there is a bug in Text. I opened an issue on Github.

1 Like

I have the same problem, could you solve it? can you tell me how?

The bottom line is that nextcloud needs to be told what to do with the file in order for the file to open when clicked. If nextcloud doesn’t know what to do with it, it can do nothing but download so that it can be handled by a local application.

For nextcloud to know what to do with a particular file type, some plugin needs to be installed that registers itself as a handler for the mime type associated with that file.