The Basics
- Nextcloud Server version (e.g., 29.x.x):
- 30.0.4
- Operating system and version (e.g., Ubuntu 24.04):
- Ubuntu 24.04
- Web server and version (e.g, Apache 2.4.25):
- Apache/2.4.58
- PHP version (e.g, 8.3):
- PHP 8.3.6
- Is this the first time you’ve seen this error? (Yes / No):
- Yes
- When did this problem seem to first start?
- When accessing files
- Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
-Example installation on Ubuntu 22.04 LTS — Nextcloud latest Administration Manual latest documentation - Are you using CloudfIare, mod_security, or similar? (Yes / No)
no
Summary of the issue you are facing:
I have a server with 10tb of files running normally, where most of the files are from coreldraw (.cdr). I need a preview for these types of files, I couldn’t get it anywhere, I decided to develop my own way of displaying the thumbnails, in my test environment my solution worked perfectly, however when I put the quantities of files and their sizes into production It makes the server very slow to the point of being almost impossible to use. I would like help to optimize this task.
Steps to replicate it (hint: details matter!):
- apt-get install inkscape
- add in file nextcloud\lib\privatePreviewManager.php
$this->registerCoreProvider(Preview\OpenDocument::class, '/application\/vnd.oasis.opendocument.*/');
$this->registerCoreProvider(Preview\CorelDraw::class, '/application\/coreldraw/');
$this->registerCoreProvider(Preview\Imaginary::class, Preview\Imaginary::supportedMimeTypes());
- add file nextcloud\lib\private\Preview\CorelDraw.php
<?php
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OC\Preview;
use OCP\Files\File;
use OCP\IImage;
use Psr\Log\LoggerInterface;
/**
* Creates thumbnails for CorelDraw (.cdr) files using Inkscape
*/
class CorelDraw extends ProviderV2 {
/**
* {@inheritDoc}
*/
public function getMimeType(): string {
return '/application\/coreldraw/';
}
/**
* Path to Inkscape executable
*/
private string $inkscapePath = '/usr/bin/inkscape';
/**
* {@inheritDoc}
*/
public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage {
$tmpPath = $this->getLocalFile($file);
if ($tmpPath === false) {
\OC::$server->get(LoggerInterface::class)->error(
'Failed to get local file for thumbnail: ' . $file->getPath(),
['app' => 'core']
);
return null;
}
// Create temporary output file for PNG
$outputPath = \OC::$server->getTempManager()->getTemporaryFile('.png');
try {
// Prepare Inkscape command
$command = escapeshellcmd($this->inkscapePath .
' "' . $tmpPath . '"' .
' --export-filename="' . $outputPath . '"' .
' --export-dpi=150');
// Execute command
exec($command . ' 2>&1', $output, $returnCode);
if ($returnCode !== 0) {
throw new \Exception('Inkscape conversion failed with code ' . $returnCode . '. Output: ' . implode("\n", $output));
}
// Verify if output file exists and has size
if (file_exists($outputPath)) {
} else {
}
// Create image from the PNG
$image = new \OCP\Image();
$loaded = $image->loadFromFile($outputPath);
// Clean up temporary files
unlink($outputPath);
$this->cleanTmpFiles();
// Resize if needed
if ($image->valid()) {
$image->scaleDownToFit($maxX, $maxY);
return $image;
} else {
}
} catch (\Exception $e) {
\OC::$server->get(LoggerInterface::class)->error(
'CorelDraw preview generation failed: ' . $file->getPath(),
[
'exception' => $e,
'app' => 'core',
]
);
// Clean up on error
if (file_exists($outputPath)) {
unlink($outputPath);
}
$this->cleanTmpFiles();
}
return null;
}
}
- add in file nextcloud\config\config.php
'enabledPreviewProviders' => [
'OC\Preview\CorelDraw',
],
Log entries
Nextcloud
Please provide the log entries from your Nextcloud log that are generated during the time of problem (via the Copy raw option from Administration settings->Logging screen or from your nextcloud.log
located in your data directory). Feel free to use a pastebin/gist service if necessary.
https://bomtech.info/nextcloud.log
Configuration
Nextcloud
The output of occ config:list system
or similar is best, but, if not possible, the contents of your config.php
file from /path/to/nextcloud
is fine (make sure to remove any identifiable information!):
root@central:/var/www2# sudo -u www-data php /var/www/occ config:list system
{
"system": {
"instanceid": "***REMOVED SENSITIVE VALUE***",
"passwordsalt": "***REMOVED SENSITIVE VALUE***",
"secret": "***REMOVED SENSITIVE VALUE***",
"trusted_domains": [
"192.168.254.3"
],
"datadirectory": "***REMOVED SENSITIVE VALUE***",
"dbtype": "mysql",
"version": "30.0.4.1",
"overwrite.cli.url": "http:\/\/192.168.254.3",
"dbname": "***REMOVED SENSITIVE VALUE***",
"dbhost": "***REMOVED SENSITIVE VALUE***",
"dbport": "",
"dbtableprefix": "oc_",
"mysql.utf8mb4": true,
"dbuser": "***REMOVED SENSITIVE VALUE***",
"dbpassword": "***REMOVED SENSITIVE VALUE***",
"installed": true,
"default_phone_region": "br",
"maintenance_window_start": 1,
"maintenance": false,
"memcache.local": "\\OC\\Memcache\\APCu",
"memcache.distributed": "\\OC\\Memcache\\Redis",
"memcache.locking": "\\OC\\Memcache\\Redis",
"apc.enable_cli": true,
"redis": {
"host": "***REMOVED SENSITIVE VALUE***",
"port": 6379,
"timeout": 0
},
"mail_smtpmode": "smtp",
"mail_smtphost": "***REMOVED SENSITIVE VALUE***",
"mail_smtpauth": 1,
"mail_smtpport": "587",
"mail_sendmailmode": "smtp",
"mail_from_address": "***REMOVED SENSITIVE VALUE***",
"mail_domain": "***REMOVED SENSITIVE VALUE***",
"mail_smtpname": "***REMOVED SENSITIVE VALUE***",
"mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
"trashbin_retention_obligation": "auto, 30",
"versions_retention_obligation": "auto, 30"
}
}
Apps
The output of occ app:list
(if possible).
root@central:/var/www2# sudo -u www-data php /var/www/occ app:list
Enabled:
- activity: 3.0.0
- app_api: 4.0.3
- bruteforcesettings: 3.0.0
- circles: 30.0.0
- cloud_federation_api: 1.13.0
- comments: 1.20.1
- contactsinteraction: 1.11.0
- dashboard: 7.10.0
- dav: 1.31.1
- federatedfilesharing: 1.20.0
- federation: 1.20.0
- files: 2.2.0
- files_downloadlimit: 3.0.0
- files_pdfviewer: 3.0.0
- files_reminders: 1.3.0
- files_sharing: 1.22.0
- files_trashbin: 1.20.1
- files_versions: 1.23.0
- firstrunwizard: 3.0.0
- logreader: 3.0.0
- lookup_server_connector: 1.18.0
- nextcloud_announcements: 2.0.0
- notifications: 3.0.0
- oauth2: 1.18.1
- password_policy: 2.0.0
- photos: 3.0.2
- privacy: 2.0.0
- provisioning_api: 1.20.0
- recommendations: 3.0.0
- related_resources: 1.5.0
- serverinfo: 2.0.0
- settings: 1.13.0
- sharebymail: 1.20.0
- support: 2.0.0
- survey_client: 2.0.0
- systemtags: 1.20.0
- text: 4.1.0
- theming: 2.5.0
- twofactor_backupcodes: 1.19.0
- updatenotification: 1.20.0
- user_status: 1.10.0
- viewer: 3.0.0
- weather_status: 1.10.0
- webhook_listeners: 1.1.0-dev
- workflowengine: 2.12.0
Disabled:
- admin_audit: 1.20.0
- encryption: 2.18.0
- files_external: 1.22.0
- previewgenerator: 5.7.0 (installed 5.7.0)
- suspicious_login: 8.0.0
- twofactor_nextcloud_notification: 4.0.0
- twofactor_totp: 12.0.0-dev
- user_ldap: 1.21.0
Tips for increasing the likelihood of a response
- Use the
preformatted text
formatting option in the editor for all log entries and configuration output. - If screenshots are useful, feel free to include them.
- If possible, also include key error output in text form so it can be searched for.
- Try to edit log output only minimally (if at all) so that it can be ran through analyzers / formatters by those trying to help you.