update nextcloud for file support

This commit is contained in:
Matthias Hochmeister
2026-03-13 13:46:08 +01:00
parent e36de3199a
commit e26d77ef35
10 changed files with 600 additions and 24 deletions

View File

@@ -68,4 +68,32 @@ export const nextcloudApi = {
.post(`/api/nextcloud/talk/rooms/${encodeURIComponent(token)}/read`)
.then(() => undefined);
},
uploadFile(
token: string,
file: File,
onProgress?: (pct: number) => void,
): Promise<void> {
const formData = new FormData();
formData.append('file', file);
return api
.post(`/api/nextcloud/talk/rooms/${encodeURIComponent(token)}/files`, formData, {
headers: { 'Content-Type': 'multipart/form-data' },
onUploadProgress: onProgress
? (e) => {
if (e.total) onProgress(Math.round((e.loaded / e.total) * 100));
}
: undefined,
})
.then(() => undefined);
},
getFileDownloadUrl(fileId: number | string, filePath?: string): string {
const base = `/api/nextcloud/talk/files/${fileId}/download`;
return filePath ? `${base}?path=${encodeURIComponent(filePath)}` : base;
},
getFilePreviewUrl(fileId: number | string, w = 400, h = 400): string {
return `/api/nextcloud/talk/files/${fileId}/preview?w=${w}&h=${h}`;
},
};