@@ -268,12 +268,12 @@ public function getCache($path = '', $storage = null): ICache {
268268 }
269269
270270 /**
271- * A custom storage implementation can return an url for direct download of a give file.
271+ * A custom storage implementation can return a url for direct download of a give file.
272272 *
273273 * For now the returned array can hold the parameter url - in future more attributes might follow.
274274 *
275275 * @param string $path
276- * @return array|false
276+ * @return array{expiration: ?int, url: ?string} |false
277277 * @throws ForbiddenException
278278 */
279279 #[\Override]
@@ -282,6 +282,32 @@ public function getDirectDownload($path): array|false {
282282 return $ this ->storage ->getDirectDownload ($ path );
283283 }
284284
285+ /**
286+ * A custom storage implementation can return a url for direct download of a give file.
287+ *
288+ * For now the returned array can hold the parameter url - in future more attributes might follow.
289+ *
290+ * @param string $fileId
291+ * @return array{expiration: ?int, url: ?string}|false
292+ * @throws ForbiddenException
293+ */
294+ #[\Override]
295+ public function getDirectDownloadById (string $ fileId ): array |false {
296+ // We first check if something is providing direct download, to save ID to path resolution
297+ $ data = $ this ->storage ->getDirectDownloadById ($ fileId );
298+ if ($ data === false ) {
299+ return false ;
300+ }
301+
302+ // We would have actually a result, so lets see if the user should be able to access it
303+ $ path = $ this ->getCache ()->getPathById ((int )$ fileId );
304+ if ($ path !== null ) {
305+ $ this ->checkFileAccess ($ path , false );
306+ }
307+
308+ return $ data ;
309+ }
310+
285311 /**
286312 * @param IStorage $sourceStorage
287313 * @param string $sourceInternalPath
0 commit comments