Fix file preview url

This commit is contained in:
Ming Ming 2023-05-28 21:19:54 +08:00
parent afa143cf10
commit 6dc0f62d23

View file

@ -42,24 +42,25 @@ String getFilePreviewUrlRelative(
required bool isKeepAspectRatio,
}) {
String url;
if (file_util.isTrash(account, file)) {
// trashbin does not support preview.png endpoint
url = "index.php/apps/files_trashbin/preview?fileId=${file.fdId}";
} else if (file_util.isNcAlbumFile(account, file)) {
if (file_util.isNcAlbumFile(account, file)) {
// We can't use the generic file preview url because collaborative albums do
// not create a file share for photos not belonging to you, that means you
// can only access the file view the Photos API
url = "apps/photos/api/v1/preview/${file.fdId}?x=$width&y=$height";
} else {
url = "index.php/core/preview?fileId=${file.fdId}";
if (file_util.isTrash(account, file)) {
// trashbin does not support preview.png endpoint
url = "index.php/apps/files_trashbin/preview?fileId=${file.fdId}";
} else {
url = "index.php/core/preview?fileId=${file.fdId}";
}
url = "$url&x=$width&y=$height";
if (mode != null) {
url = "$url&mode=$mode";
}
// keep this here to use cache from older version
url = "$url&a=${isKeepAspectRatio ? 1 : 0}";
}
url = "$url&x=$width&y=$height";
if (mode != null) {
url = "$url&mode=$mode";
}
// keep this here to use cache from older version
url = "$url&a=${isKeepAspectRatio ? 1 : 0}";
return url;
}