1
0
Fork 0
mirror of synced 2024-06-16 17:34:41 +12:00
budibase/packages/server/src/api/controllers/plugin/file.ts

16 lines
443 B
TypeScript

import {
createTempFolder,
getPluginMetadata,
extractTarball,
} from "../../../utilities/fileSystem"
export async function fileUpload(file: { name: string; path: string }) {
if (!file.name.endsWith(".tar.gz")) {
throw new Error("Plugin must be compressed into a gzipped tarball.")
}
const path = createTempFolder(file.name.split(".tar.gz")[0])
await extractTarball(file.path, path)
return await getPluginMetadata(path)
}