diff --git a/composer.lock b/composer.lock index 5f1c434a..78c60c68 100644 --- a/composer.lock +++ b/composer.lock @@ -1785,12 +1785,12 @@ "source": { "type": "git", "url": "https://github.com/nextcloud-deps/ocp.git", - "reference": "b831025b4235e2afcd11be1f319ae923a44e5fa1" + "reference": "d42bd36d0413b881b7459b220e1328bc57e48b38" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nextcloud-deps/ocp/zipball/b831025b4235e2afcd11be1f319ae923a44e5fa1", - "reference": "b831025b4235e2afcd11be1f319ae923a44e5fa1", + "url": "https://api.github.com/repos/nextcloud-deps/ocp/zipball/d42bd36d0413b881b7459b220e1328bc57e48b38", + "reference": "d42bd36d0413b881b7459b220e1328bc57e48b38", "shasum": "" }, "require": { @@ -1826,7 +1826,7 @@ "issues": "https://github.com/nextcloud-deps/ocp/issues", "source": "https://github.com/nextcloud-deps/ocp/tree/master" }, - "time": "2025-12-06T00:51:12+00:00" + "time": "2025-12-11T00:55:32+00:00" }, { "name": "nikic/php-parser", diff --git a/lib/StorageWrapper.php b/lib/StorageWrapper.php index 04cc103e..d395d636 100644 --- a/lib/StorageWrapper.php +++ b/lib/StorageWrapper.php @@ -268,12 +268,12 @@ public function getCache($path = '', $storage = null): ICache { } /** - * A custom storage implementation can return an url for direct download of a give file. + * A custom storage implementation can return a url for direct download of a give file. * * For now the returned array can hold the parameter url - in future more attributes might follow. * * @param string $path - * @return array|false + * @return array{expiration: ?int, url: ?string}|false * @throws ForbiddenException */ #[\Override] @@ -282,6 +282,32 @@ public function getDirectDownload($path): array|false { return $this->storage->getDirectDownload($path); } + /** + * A custom storage implementation can return a url for direct download of a give file. + * + * For now the returned array can hold the parameter url - in future more attributes might follow. + * + * @param string $fileId + * @return array{expiration: ?int, url: ?string}|false + * @throws ForbiddenException + */ + #[\Override] + public function getDirectDownloadById(string $fileId): array|false { + // We first check if something is providing direct download, to save ID to path resolution + $data = $this->storage->getDirectDownloadById($fileId); + if ($data === false) { + return false; + } + + // We would have actually a result, so lets see if the user should be able to access it + $path = $this->getCache()->getPathById((int)$fileId); + if ($path !== null) { + $this->checkFileAccess($path, false); + } + + return $data; + } + /** * @param IStorage $sourceStorage * @param string $sourceInternalPath