mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
refac: uploads delete
This commit is contained in:
@@ -150,3 +150,34 @@ export const deleteFileById = async (token: string, id: string) => {
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
export const deleteAllFiles = async (token: string) => {
|
||||
let error = null;
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/files/all`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
authorization: `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (!res.ok) throw await res.json();
|
||||
return res.json();
|
||||
})
|
||||
.then((json) => {
|
||||
return json;
|
||||
})
|
||||
.catch((err) => {
|
||||
error = err.detail;
|
||||
console.log(err);
|
||||
return null;
|
||||
});
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { getDocs } from '$lib/apis/documents';
|
||||
import { deleteAllFiles, deleteFileById } from '$lib/apis/files';
|
||||
import {
|
||||
getQuerySettings,
|
||||
scanDocs,
|
||||
@@ -217,8 +218,8 @@
|
||||
|
||||
<ResetUploadDirConfirmDialog
|
||||
bind:show={showResetUploadDirConfirm}
|
||||
on:confirm={() => {
|
||||
const res = resetUploadDir(localStorage.token).catch((error) => {
|
||||
on:confirm={async () => {
|
||||
const res = await deleteAllFiles(localStorage.token).catch((error) => {
|
||||
toast.error(error);
|
||||
return null;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user