NextCloud – ошибка при загрузке изображения, видео файла

Print Friendly, PDF & Email

Задача:

Исправить ошибку nextcloud при открытии видео или аудио файлов в браузере

---------------------------------------------------------------

Пробуем открыть файл и сразу смотрим, что записалось в логах: “Настройки > Журналирование”

По дате и времени находим, какая запись в логах соответствует попытке открыть файл.

[index] Error: OCP\Files\NotPermittedException: Could not create folder at <<closure>>

 0. /usr/local/www/nextcloud/lib/private/Files/AppData/AppData.php line 158
    OC\Files\Node\Folder->newFolder("920872")
 1. /usr/local/www/nextcloud/lib/private/Preview/Generator.php line 433
    OC\Files\AppData\AppData->newFolder("920872")
 2. /usr/local/www/nextcloud/lib/private/Preview/Generator.php line 119
    OC\Preview\Generator->getPreviewFolder(OC\Files\Node\File {})
 3. /usr/local/www/nextcloud/lib/private/PreviewManager.php line 185
    OC\Preview\Generator->getPreview(OC\Files\Node\File {}, 1920, 1080, false, "fill", "image/jpeg")
 4. /usr/local/www/nextcloud/core/Controller/PreviewController.php line 172
    OC\PreviewManager->getPreview(OC\Files\Node\File {}, 1920, 1080, false, "fill")
 5. /usr/local/www/nextcloud/core/Controller/PreviewController.php line 144
    OC\Core\Controller\PreviewController->fetchPreview(OC\Files\Node\File {}, 1920, 1080, true, true, "fill")
 6. /usr/local/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 170
    OC\Core\Controller\PreviewController->getPreviewByFileId(920872, 1920, 1080, true, true, "fill")
 7. /usr/local/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 99
    OC\AppFramework\Http\Dispatcher->executeController(OC\Core\Controller\PreviewController {}, "getPreviewByFileId")
 8. /usr/local/www/nextcloud/lib/private/AppFramework/App.php line 125
    OC\AppFramework\Http\Dispatcher->dispatch(OC\Core\Controller\PreviewController {}, "getPreviewByFileId")
 9. /usr/local/www/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php line 47
    OC\AppFramework\App::main("OC\\Core\\Controller\\PreviewController", "getPreviewByFileId", OC\AppFramework\ ... {}, {_route: "core.P ... "})
10. <<closure>>
    OC\AppFramework\Routing\RouteActionHandler->__invoke({_route: "core.P ... "})
11. /usr/local/www/nextcloud/lib/private/Route/Router.php line 299
    call_user_func(OC\AppFramework\ ... {}, {_route: "core.P ... "})
12. /usr/local/www/nextcloud/lib/base.php line 1008
    OC\Route\Router->match("/core/preview")
13. /usr/local/www/nextcloud/index.php line 38
    OC::handleRequest()

GET /core/preview?fileId=920872&x=1920&y=1080&a=true
from 192.168.17.231 by admin at 2020-05-23T11:57:51+00:00

Из логов видно, что ошибка прав доступа. Nextcloud не может создать папку.

OCP\Files\NotPermittedException: Could not create folder

Авторизуемся в консоли сервера и проверяем какой веб сервер у нас используется

сurl --insecure --silent --show-error --connect-timeout 1 -I http://localhost | grep Server

Или можно узнать более короткой командой

root@cloud:/ # curl -I http://localhost
HTTP/1.1 404 Not Found
Server: nginx/1.16.1
Date: Sat, 23 May 2020 11:24:15 GMT
Content-Type: text/html
Content-Length: 153
Connection: keep-alive

root@cloud:/ #

Теперь необходимо узнать пользователя от кого работает nginx

root@cloud:/ # ps aux | grep nginx
root    781   0.0  0.1   32268    9500  -  Is   28Apr20      0:00.31 nginx: master process /usr/local/sbin/nginx
www    4314   0.0  0.1   29476   11756  -  S     8May20     18:37.97 nginx: worker process (nginx)
root   8480   0.0  0.0   11260    2716  0  S+   13:33        0:00.00 grep nginx
root@cloud:/ #

в какой группе состоит пользователь www

root@cloud:/ # groups www
www
root@cloud:/ # 

После того как мы получили нужную информацию, переходим в веб-директорию nextcloud

root@cloud:/ # cd /usr/local/www/
root@cloud:/usr/local/www #

назвачаем необходимые права на файлы и директории

chown -R www:www nextcloud
find nextcloud/ -type d -exec chmod 750 {} \;
find nextcloud/ -type f -exec chmod 640 {} \;

может быть, что файлы пользователей лежат в другой директории. Проверяем

root@cloud:/usr/local/www # cat nextcloud/config/config.php | grep datadir
  'datadirectory' => '/mnt/da1p1/data',
root@cloud:/usr/local/www #

назначаем нужные права на папку

root@cloud:/ # cd /mnt/da1p1
root@cloud:/mnt/da1p1 # chown -R www:www data
root@cloud:/mnt/da1p1 # find data/ -type d -exec chmod 750 {} \;
root@cloud:/mnt/da1p1 # find data/ -type f -exec chmod 640 {} \;

Пробуем генерировать файлы предварительного просмотра самостоятельно

root@cloud:/usr/local/www/nextcloud # sudo -u www php occ preview:pre-generate
The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php
2020-06-03T22:17:59+00:00
2020-06-03T22:17:59+00:00 In Folder.php line 164:
2020-06-03T22:17:59+00:00
2020-06-03T22:17:59+00:00   Could not create folder
2020-06-03T22:17:59+00:00
2020-06-03T22:17:59+00:00
2020-06-03T22:17:59+00:00 preview:pre-generate
2020-06-03T22:17:59+00:00
root@cloud:/usr/local/www/nextcloud #sudo -u www php occ preview:pre-generate -vvvv
The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php
2020-06-03T22:37:43+00:00 Generating previews for /virzai/files/Автозагрузка/WhatsApp Images/IMG-20200506-WA0019.jpg
2020-06-03T22:37:43+00:00
2020-06-03T22:37:43+00:00 In Folder.php line 164:
2020-06-03T22:37:43+00:00
2020-06-03T22:37:43+00:00   [OCP\Files\NotPermittedException]
2020-06-03T22:37:43+00:00   Could not create folder
2020-06-03T22:37:43+00:00
2020-06-03T22:37:43+00:00
2020-06-03T22:37:43+00:00 Exception trace:
2020-06-03T22:37:43+00:00   at /usr/local/www/nextcloud/lib/private/Files/Node/Folder.php:164
2020-06-03T22:37:43+00:00  OC\Files\Node\Folder->newFolder() at /usr/local/www/nextcloud/lib/private/Files/AppData/AppData.php:158
2020-06-03T22:37:43+00:00  OC\Files\AppData\AppData->newFolder() at /usr/local/www/nextcloud/lib/private/Preview/Generator.php:433
2020-06-03T22:37:43+00:00  OC\Preview\Generator->getPreviewFolder() at /usr/local/www/nextcloud/lib/private/Preview/Generator.php:119
2020-06-03T22:37:43+00:00  OC\Preview\Generator->getPreview() at /usr/local/www/nextcloud/lib/private/PreviewManager.php:185
2020-06-03T22:37:43+00:00  OC\PreviewManager->getPreview() at /usr/local/www/nextcloud/apps/previewgenerator/lib/Command/PreGenerate.php:205
2020-06-03T22:37:43+00:00  OCA\PreviewGenerator\Command\PreGenerate->processFile() at /usr/local/www/nextcloud/apps/previewgenerator/lib/Command/PreGenerate.php:193
2020-06-03T22:37:43+00:00  OCA\PreviewGenerator\Command\PreGenerate->processRow() at /usr/local/www/nextcloud/apps/previewgenerator/lib/Command/PreGenerate.php:164
2020-06-03T22:37:43+00:00  OCA\PreviewGenerator\Command\PreGenerate->startProcessing() at /usr/local/www/nextcloud/apps/previewgenerator/lib/Command/PreGenerate.php:132
2020-06-03T22:37:43+00:00  OCA\PreviewGenerator\Command\PreGenerate->execute() at /usr/local/www/nextcloud/3rdparty/symfony/console/Command/Command.php:255
2020-06-03T22:37:43+00:00  Symfony\Component\Console\Command\Command->run() at /usr/local/www/nextcloud/3rdparty/symfony/console/Application.php:915
2020-06-03T22:37:43+00:00  Symfony\Component\Console\Application->doRunCommand() at /usr/local/www/nextcloud/3rdparty/symfony/console/Application.php:272
2020-06-03T22:37:43+00:00  Symfony\Component\Console\Application->doRun() at /usr/local/www/nextcloud/3rdparty/symfony/console/Application.php:148
2020-06-03T22:37:43+00:00  Symfony\Component\Console\Application->run() at /usr/local/www/nextcloud/lib/private/Console/Application.php:214
2020-06-03T22:37:43+00:00  OC\Console\Application->run() at /usr/local/www/nextcloud/console.php:99
2020-06-03T22:37:43+00:00  require_once() at /usr/local/www/nextcloud/occ:11
2020-06-03T22:37:43+00:00
2020-06-03T22:37:43+00:00 preview:pre-generate
2020-06-03T22:37:43+00:00
root@cloud:/usr/local/www/nextcloud #

Удаляем папку data/appdata_*

rm -r /mnt/da1p1/data/appdata_*

Пробуем пересканировать файлы приложений

root@cloud:/usr/local/www/nextcloud # sudo -u www php occ files:scan-app-data
The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php

Scanning AppData for files
Path not found: /appdata_ocf5begso4j5

+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 0       | 0     | 00:00:00     |
+---------+-------+--------------+

Запускаем режим восстановления и ещё раз сканирование файлов приложений

root@cloud:/usr/local/www/nextcloud # sudo -u www php occ maintenance:repair
The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php
 - Repair MySQL collation
     - All tables already have the correct collation -> nothing to do
 - Repair mime types
 - Clean tags and favorites
     - 0 tags of deleted users have been removed.
     - 0 tags for delete files have been removed.
     - 0 tag entries for deleted tags have been removed.
     - 0 tags with no entries have been removed.
 - Repair invalid shares
 - Move .step file of updater to backup location
 - Fix potential broken mount points
     - No mounts updated
 - Add log rotate job
 - Clear frontend caches
     - Image cache cleared
     - SCSS cache cleared
     - JS cache cleared
 - Clear every generated avatar on major updates
 - Add preview background cleanup job
 - Queue a one-time job to cleanup old backups of the updater
 - Cleanup invalid photocache files for carddav
 - Add background job to cleanup login flow v2 tokens
 - Remove potentially over exposing share links
     - No need to remove link shares.
 - Clear access cache of projects
 - Switches from deprecated "production" to "stable" update channel
 - Sets the enterprise logo
     - Repair step already executed
 - Reset generated avatar flag
 - Update name of the stored view
 - Fix component of birthday calendars
     - 4 birthday calendars updated.
 - Regenerating birthday calendars to use new icons and fix old birthday events without year
     - Repair step already executed
 - Fix broken values of calendar objects
    0 [>---------------------------]
 - Registering building of calendar search index as background job
     - Repair step already executed
 - Registering background jobs to update cache for webcal calendars
     - Added 0 background jobs to update webcal calendars
 - Registering building of calendar reminder index as background job
     - Repair step already executed
 - Clean up orphan event and contact data
     - 0 events without a calendar have been cleaned up
     - 0 properties without an events have been cleaned up
     - 0 changes without a calendar have been cleaned up
     - 0 cached events without a calendar subscription have been cleaned up
     - 0 changes without a calendar subscription have been cleaned up
     - 0 contacts without an addressbook have been cleaned up
     - 0 properties without a contact have been cleaned up
     - 0 changes without an addressbook have been cleaned up
 - Remove activity entries of private events
     - Removed 0 activity entries
 - Delete orphaned ACL rules
 - Copy default images to the app data directory
     - Icon %s copied successfully
     - Icon %s copied successfully
     - Icon %s copied successfully
 - Fix the share type of guest shares when migrating from ownCloud
 - Copy the share password into the dedicated column
 - Set existing shares as accepted
 - Purify and migrate collected mail addresses
    0 [>---------------------------]
 - Insert sync background job for all accounts
 1/1 [============================] 100%
 - Make Mail itinerary extractor executable
 - Migrate Mail provisioning config from config.php to the database
     - No old config found
 - Create or update provisioned Mail accounts
     - No Mail provisioning config set
 - Remove any playlist files mistakenly added to music_tracks table
 - Combine multi-disk albums and store disk numbers per track
 - Set creation date for playlists without one
 - Migrate binary status into separate boolean fields
 - Update OAuth token expiration times
 - Repair Passwords Database Objects
     - Checking 0 tag revisions
    0 [>---------------------------]
     - Fixed 0 tag revisions
     - Checking 2 folder revisions
 2/2 [============================] 100%
     - Fixed 0 folder revisions
     - Checking 38 password revisions
 38/38 [============================] 100%
     - Fixed 0 password revisions
     - Checking 0 tag models
    0 [>---------------------------]
     - Fixed 0 tag models
     - Checking 1 folder models
 1/1 [============================] 100%
     - Fixed 0 folder models
     - Checking 21 password models
 21/21 [============================] 100%
     - Fixed 0 password models
     - Checking 0 password tag relations
    0 [>---------------------------]
     - Fixed 0 password tag relations
 - Create help command
 - Invalidate access cache for projects conversation provider
     - Invalidation not required
 - Add background job to check for backup codes
 - Populating added database structures for workflows
root@cloud:/usr/local/www/nextcloud # sudo -u www php occ files:scan-app-data
The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php

Scanning AppData for files

+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 6       | 3     | 00:00:00     |
+---------+-------+--------------+

Запускаем создание изображений

root@cloud:/usr/local/www/nextcloud # sudo -u www php occ preview:pre-generate -vvvv
The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php
2020-06-03T22:48:37+00:00 Generating previews for /virzai/files/Автозагрузка/WhatsApp Images/IMG-20200427-WA0003.jpg
2020-06-03T22:48:39+00:00 Generating previews for /virzai/files/Автозагрузка/WhatsApp Images/IMG-20200503-WA0008.jpg
2020-06-03T22:48:40+00:00 Generating previews for /virzai/files/Автозагрузка/WhatsApp Images/IMG-20200427-WA0020.jpg
2020-06-03T22:48:43+00:00 Generating previews for /virzai/files/Автозагрузка/WhatsApp Images/IMG-20200414-WA0041.jpg

После этого всё работало!

Помогла статья? Есть возможность отблагодарить автора

Читайте также:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *