Skip to content

Conversation

@danxuliu
Copy link
Member

@danxuliu danxuliu commented May 6, 2025

The PDF viewer must be able to download the file to show it, and if the file is not downloadable an error message was just shown. However, Nextcloud Office ("richdocuments") is able to show PDF files even if they can not be downloaded, so now the viewer is reopened forcing "richdocuments" to handle opening the file when it is not downloadable.

Although this will make possible to show public shares with "Hide download" enabled in Nextcloud 31.0.0 to 31.0.4 (as it behaved as "Prevent download" until the previous behaviour was restored) note that this fix applies mainly to internal shares, so it needs to be backported up to Nextcloud 30.

The fix is a bit hacky, as it opens again the file while it was being already being opened, but unfortunately I did not find any better approach with the current Viewer API. Hopefully with conditional handlers in the Viewer 4.0 API it will be possible to directly open Nextcloud Office if the file does not have download permissions :-)

How to test

  • Setup Nextcloud Office
  • Open the Files app
  • Upload a PDF file
  • Share the file with another user
  • Custom the share permissions and uncheck Allow download and sync
  • In a private window, log in as the other user
  • Open the Files app
  • Open the PDF file

Result with this pull request

Nextcloud Office shows the PDF file

Result without this pull request

The PDF viewer shows To view a shared PDF file, the download needs to be allowed for this file share

@danxuliu
Copy link
Member Author

danxuliu commented May 6, 2025

/compile amend /

The PDF viewer must be able to download the file to show it, and if the
file is not downloadable an error message was just shown. However,
Nextcloud Office ("richdocuments") is able to show PDF files even if
they can not be downloaded, so now the viewer is reopened forcing
"richdocuments" to handle opening the file when it is not downloadable.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
Copy link
Collaborator

@szaimen szaimen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐘

@szaimen szaimen merged commit 5ddcc1d into master May 6, 2025
36 checks passed
@danxuliu danxuliu deleted the open-pdf-file-in-richdocuments-if-it-is-not-downloadable branch May 6, 2025 09:16
@asomy23
Copy link

asomy23 commented May 13, 2025

Hello,
I have installed version 31.0.5 (beta), and the issue with public links has been resolved. However, when sharing files internally without selecting "Allow download and sync", users are unable to view PDF files.

Could you please look into this?

Internally share

Thank you all

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants