view image files
This commit is contained in:
@@ -265,3 +265,35 @@ export async function renameWarrenEntry(
|
||||
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
export async function fetchFile(
|
||||
warrenId: string,
|
||||
path: string,
|
||||
fileName: string
|
||||
): Promise<{ success: true; data: Blob } | { success: false }> {
|
||||
if (!path.endsWith('/')) {
|
||||
path += '/';
|
||||
}
|
||||
path += fileName;
|
||||
|
||||
const { data, error } = await useFetch<Blob>(
|
||||
getApiUrl(`warrens/files/fetch?warrenId=${warrenId}&path=${path}`),
|
||||
{
|
||||
method: 'GET',
|
||||
headers: getApiHeaders(),
|
||||
responseType: 'blob',
|
||||
cache: 'default',
|
||||
}
|
||||
);
|
||||
|
||||
if (data.value == null || error.value != null) {
|
||||
return {
|
||||
success: false,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: data.value,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user