feat: support upload pkg

This commit is contained in:
Joel
2024-10-24 17:14:17 +08:00
parent d7def41acc
commit 606fc7be0c
8 changed files with 62 additions and 27 deletions

View File

@ -1,5 +1,5 @@
import type { Fetcher } from 'swr'
import { del, get, post } from './base'
import { del, get, post, upload } from './base'
import type {
CreateEndpointRequest,
EndpointOperationResponse,
@ -49,3 +49,12 @@ export const installPackageFromGitHub: Fetcher<InstallPackageResponse, { repo: s
export const fetchDebugKey = async () => {
return get<DebugInfoTypes>('/workspaces/current/plugin/debugging-key')
}
export const uploadPackageFile = async (file: File) => {
const formData = new FormData()
formData.append('pkg', file)
return upload({
xhr: new XMLHttpRequest(),
data: formData,
}, false, '/workspaces/current/plugin/upload/pkg')
}