enh: files data controls
This commit is contained in:
1 parent
a10ac774ab
commit
93ed4ae2cd
5 files changed
+443
-4
No files matched your search
@@ -175,6 +175,44 @@ export const getFiles = async (token: string = '') => {
|
||||
return res;
|
||||
};
|
||||
|
||||
export const searchFiles = async (
|
||||
token: string,
|
||||
filename: string = '*',
|
||||
skip: number = 0,
|
||||
limit: number = 50
|
||||
) => {
|
||||
let error = null;
|
||||
|
||||
const searchParams = new URLSearchParams();
|
||||
searchParams.append('filename', filename);
|
||||
searchParams.append('skip', String(skip));
|
||||
searchParams.append('limit', String(limit));
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/files/search?${searchParams.toString()}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
authorization: `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (!res.ok) throw await res.json();
|
||||
return res.json();
|
||||
})
|
||||
.catch((err) => {
|
||||
error = err.detail;
|
||||
console.error(err);
|
||||
return [];
|
||||
});
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
export const getFileById = async (token: string, id: string) => {
|
||||
let error = null;
|
||||
|
||||
|
||||
Reference in new issue
Block a user