show image preview + single file downloads

This commit is contained in:
2025-08-10 23:16:18 +02:00
parent bfe73eefb9
commit c8b52a5b3b
13 changed files with 174 additions and 26 deletions

View File

@@ -301,6 +301,40 @@ export async function fetchFile(
};
}
export async function fetchFileStream(
warrenId: string,
path: string,
fileName: string
): Promise<
{ success: true; stream: ReadableStream<Uint8Array> } | { success: false }
> {
if (!path.endsWith('/')) {
path += '/';
}
path += fileName;
const { data, error } = await useFetch<ReadableStream<Uint8Array>>(
getApiUrl(`warrens/files/cat?warrenId=${warrenId}&path=${path}`),
{
method: 'GET',
headers: getApiHeaders(),
responseType: 'stream',
cache: 'default',
}
);
if (data.value == null || error.value != null) {
return {
success: false,
};
}
return {
success: true,
stream: data.value,
};
}
export async function moveFile(
warrenId: string,
currentPath: string,