Unable to generate preview ( File not found even though file is found)

I am facing this issue where I am trying to generate a preview of a pdf file however for some reason it says File not found which is odd because the file is present

The preview system was working fine like 4months ago. But now after I updated it I face this issue. The preview system in nextcloud has been bugging me ever since I started using nextcloud 8 years ago. And still its just randomness of sometimes it works and sometimes it doesn’t

Below Image is the docker container shell that I got into using docker exec -u 33 -it nextcloud-app /bin/bash

here is more info on the 2yn.pdf permissions

www-data@8e645b6899f5:~/html/data/Administrator/files/GoodNotes$ ls -alh 2yn.pdf
-rw-r--r-- 1 www-data www-data 217K May 31 14:33 2yn.pdf

I am running nextcloud docker

services:
  db:
    container_name: nextcloud-mariadb
    image: mariadb:lts
    command: --transaction-isolation=READ-COMMITTED
    volumes:
      - /home/pi/data/nextcloud/db:/var/lib/mysql
    environment:
      - TZ=Asia/Kolkata
      - MYSQL_ROOT_PASSWORD=raspberry
      - MYSQL_PASSWORD=raspberry
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
    # restart: always
    labels:
      - sablier.enable=true
      - sablier.group=nextcloud
    healthcheck:
      test: ["CMD", "mariadb-admin", "-uroot", "-praspberry", "ping"]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 10s

  redis:
    container_name: nextcloud-redis
    image: redis:alpine
    environment:
      - TZ=Asia/Kolkata
    # restart: always
    labels:
      - sablier.enable=true
      - sablier.group=nextcloud
    healthcheck:
      test: ["CMD", "redis-cli", "-h", "localhost", "ping"]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 10s

  app:
    container_name: nextcloud-app
    image: nextcloud:fpm
    depends_on:
      - redis
      - db
    volumes:
      - /home/pi/data/nextcloud/nextcloud:/var/www/html
      - /media/pi/SSD:/ssd
    environment:
      - TZ=Asia/Kolkata
      - MYSQL_PASSWORD=raspberry
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=db
    # restart: always
    labels:
      - sablier.enable=true
      - sablier.group=nextcloud
    healthcheck:
      test: ["CMD", "su", "-s", "/bin/sh", "www-data", "-c", "php /var/www/html/occ status | grep -q 'installed: true'"]
      interval: 60s
      retries: 5
      start_period: 10s
      timeout: 10s

  web:
    container_name: nextcloud-web
    image: nginx:alpine-slim
    ports:
      - 8092:80
    environment:
      - TZ=Asia/Kolkata
    depends_on:
      - app
    volumes:
      - /home/pi/data/nextcloud/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
    volumes_from:
      - app
    # restart: always
    labels:
      - sablier.enable=true
      - sablier.group=nextcloud
    healthcheck:
      test: ["CMD", "wget", "--spider", "--timeout=5", "http://127.0.0.1/status.php"]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 10s

volumes:
  nextcloud:
  db:

I believe the path should be relative to the Nextcloud datadirectory. e.g.

In this case, try occ preview:generate /Administrator/files/GoodNotes/2yn.pdf

thank you for the response.
I tried the above command and I get this, I also ran occ app:list to see if I have preview generator installed, which I do.

www-data@a132588d7934:~/html$ ./occ preview:generate /Administrator/files/GoodNotes/2yn.pdf

In Generator.php line 366:
                                                           
  No provider successfully handled the preview generation  
                                                           

preview:generate [-s|--size SIZE] [-c|--crop] [-m|--mode MODE] [--] <file>

www-data@a132588d7934:~/html$ ./occ app:list
Enabled:
  - activity: 4.0.0
  - app_api: 5.0.2
  - bruteforcesettings: 4.0.0
  - circles: 31.0.0
  - cloud_federation_api: 1.14.0
  - comments: 1.21.0
  - contactsinteraction: 1.12.0
  - dashboard: 7.11.0
  - dav: 1.33.0
  - federatedfilesharing: 1.21.0
  - federation: 1.21.0
  - files: 2.3.1
  - files_downloadlimit: 4.0.0
  - files_external: 1.23.0
  - files_pdfviewer: 4.0.0
  - files_reminders: 1.4.0
  - files_sharing: 1.23.1
  - files_trashbin: 1.21.0
  - files_versions: 1.24.0
  - firstrunwizard: 4.0.0
  - logreader: 4.0.0
  - lookup_server_connector: 1.19.0
  - nextcloud_announcements: 3.0.0
  - notifications: 4.0.0
  - oauth2: 1.19.1
  - password_policy: 3.0.0
  - photos: 4.0.0
  - previewgenerator: 5.9.0
  - privacy: 3.0.0
  - profile: 1.0.0
  - provisioning_api: 1.21.0
  - recommendations: 4.0.0
  - related_resources: 2.0.0
  - serverinfo: 3.0.0
  - settings: 1.14.0
  - sharebymail: 1.21.0
  - support: 3.0.0
  - survey_client: 3.0.0
  - systemtags: 1.21.1
  - text: 5.0.0
  - theming: 2.6.1
  - twofactor_backupcodes: 1.20.0
  - updatenotification: 1.21.0
  - user_status: 1.11.0
  - viewer: 4.0.0
  - weather_status: 1.11.0
  - webhook_listeners: 1.2.0
  - workflowengine: 2.13.0
Disabled:
  - admin_audit: 1.21.0
  - encryption: 2.19.0
  - suspicious_login: 9.0.1
  - twofactor_nextcloud_notification: 5.0.0
  - twofactor_totp: 13.0.0-dev.0
  - user_ldap: 1.22.0

I also see these logs

Requesting preview for /Administrator/files/SSD/eBooks/Newspaper/today.pdf with width=250, height=250, crop=true, mode=fill, mimeType=null

Calling preview provider for application/pdf with width=2048, height=2048

ImagickException
attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/426
File: /Administrator/files/SSD/eBooks/Newspaper/today.pdf Imagick says:

https://www.baeldung.com/linux/imagemagick-security-policy#2-remove-restriction

Note that you’ll likely want to mount the policy file somewhere in order to retain it through container upgrades.

If you want an easier approach, the AIO stack is another option.

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.