show image preview + single file downloads
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user