diff --git a/config/config.sample.php b/config/config.sample.php index 947666e089592..5d6cfa3d3c2c7 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -2320,6 +2320,18 @@ */ 'files_external_allow_create_new_local' => true, +/** + * Controls whether to attempt downloading the entire file for preview generation + * on non-local storage (e.g., S3, WebDAV) when the initial 5 MB chunk fails to provide + * sufficient data for a preview. By default, only the first 5 MB of a file is parsed. + * + * Enabling this option may significantly increase bandwidth usage and processing time + * for large files on external storages. + * + * * Defaults to ``false`` + */ +'files_external_full_previews' => false, + /** * Specifies how often the local filesystem (the Nextcloud data/ directory, and * NFS mounts in data/) is checked for changes made outside Nextcloud. This diff --git a/lib/private/Preview/Movie.php b/lib/private/Preview/Movie.php index 47895f999d810..894355b0511cd 100644 --- a/lib/private/Preview/Movie.php +++ b/lib/private/Preview/Movie.php @@ -18,7 +18,6 @@ class Movie extends ProviderV2 { private IConfig $config; - private ?string $binary = null; public function __construct(array $options = []) { @@ -57,11 +56,10 @@ public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { // Try downloading 5 MB first, as it's likely that the first frames are present there. // In some cases this doesn't work, for example when the moov atom is at the // end of the file, so if it fails we fall back to getting the full file. - // Unless the file is not local (e.g. S3) as we do not want to download the whole (e.g. 37Gb) file - if ($file->getStorage()->isLocal()) { - $sizeAttempts = [5242880, null]; - } else { - $sizeAttempts = [5242880]; + $sizeAttempts = [5242880]; + $fullPreviews = $this->config->getSystemValueBool('files_external_full_previews', false); + if ($file->getStorage()->isLocal() || $fullPreviews === true) { + $sizeAttempts[] = null; } } else { // size is irrelevant, only attempt once