fix: resolve public share downloads and sort storage overview by size
All checks were successful
Automated Container Build / build-and-push (push) Successful in 35s
All checks were successful
Automated Container Build / build-and-push (push) Successful in 35s
This commit is contained in:
parent
fb3f3a3393
commit
5c2eaf49e4
2 changed files with 13 additions and 4 deletions
|
|
@ -19,6 +19,7 @@ export default function PublicSharePage({ params }: { params: Promise<{ id: stri
|
|||
const [error, setError] = useState<string | null>(null);
|
||||
const [requirePassword, setRequirePassword] = useState(false);
|
||||
const [password, setPassword] = useState('');
|
||||
const [token, setToken] = useState('');
|
||||
const [fileInfo, setFileInfo] = useState<FileInfo | null>(null);
|
||||
const [currentPath, setCurrentPath] = useState('');
|
||||
|
||||
|
|
@ -36,6 +37,12 @@ export default function PublicSharePage({ params }: { params: Promise<{ id: stri
|
|||
} else {
|
||||
setRequirePassword(false);
|
||||
setFileInfo(data);
|
||||
try {
|
||||
const t = await api.createPublicShareToken(id, pwd);
|
||||
setToken(t);
|
||||
} catch (e) {
|
||||
console.error("Failed to fetch token", e);
|
||||
}
|
||||
}
|
||||
} catch (err: any) {
|
||||
if (err.require_password) {
|
||||
|
|
@ -55,7 +62,7 @@ export default function PublicSharePage({ params }: { params: Promise<{ id: stri
|
|||
|
||||
function handleDownload(specificPath?: string) {
|
||||
const downloadPath = specificPath ? (currentPath ? `${currentPath}/${specificPath}` : specificPath) : currentPath;
|
||||
const url = api.getPublicDownloadUrl(id, password, downloadPath);
|
||||
const url = api.getPublicDownloadUrl(id, token, downloadPath);
|
||||
window.location.href = url;
|
||||
}
|
||||
|
||||
|
|
@ -136,7 +143,7 @@ export default function PublicSharePage({ params }: { params: Promise<{ id: stri
|
|||
const isVideo = !fileInfo?.is_dir && fileInfo?.mime_type?.startsWith('video/');
|
||||
const isAudio = !fileInfo?.is_dir && fileInfo?.mime_type?.startsWith('audio/');
|
||||
const isPdf = !fileInfo?.is_dir && fileInfo?.mime_type === 'application/pdf';
|
||||
const downloadUrl = fileInfo ? api.getPublicDownloadUrl(id, password, currentPath) : '';
|
||||
const downloadUrl = fileInfo && token ? api.getPublicDownloadUrl(id, token, currentPath) : '';
|
||||
|
||||
// Breadcrumbs
|
||||
const pathParts = currentPath.split('/').filter(Boolean);
|
||||
|
|
|
|||
Reference in a new issue