update file manager

This commit is contained in:
Qing
2023-01-01 22:36:11 +08:00
parent 39397fc829
commit 2e8e52f7a5
7 changed files with 79 additions and 112 deletions

View File

@@ -110,6 +110,12 @@ export function getIsDisableModelSwitch() {
})
}
export function getEnableFileManager() {
return fetch(`${API_ENDPOINT}/is_enable_file_manager`, {
method: 'GET',
})
}
export function switchModel(name: string) {
const fd = new FormData()
fd.append('name', name)
@@ -166,9 +172,12 @@ export async function postInteractiveSeg(
}
export async function getMediaFile(filename: string) {
const res = await fetch(`${API_ENDPOINT}/media/${filename}`, {
method: 'GET',
})
const res = await fetch(
`${API_ENDPOINT}/media/${encodeURIComponent(filename)}`,
{
method: 'GET',
}
)
if (res.ok) {
const blob = await res.blob()
const file = new File([blob], filename)
@@ -177,3 +186,15 @@ export async function getMediaFile(filename: string) {
const errMsg = await res.text()
throw new Error(errMsg)
}
export async function getMedias() {
const res = await fetch(`${API_ENDPOINT}/medias`, {
method: 'GET',
})
if (res.ok) {
const filenames = await res.json()
return filenames
}
const errMsg = await res.text()
throw new Error(errMsg)
}