Support generating a compressed archive for a server via the API
This commit is contained in:
@@ -83,6 +83,7 @@ func Configure() *gin.Engine {
|
||||
files.POST("/write", postServerWriteFile)
|
||||
files.POST("/create-directory", postServerCreateDirectory)
|
||||
files.POST("/delete", postServerDeleteFile)
|
||||
files.POST("/compress", postServerCompressFiles)
|
||||
}
|
||||
|
||||
backup := server.Group("/backup")
|
||||
|
||||
@@ -3,6 +3,7 @@ package router
|
||||
import (
|
||||
"bufio"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/pterodactyl/wings/server"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
@@ -188,3 +189,27 @@ func postServerCreateDirectory(c *gin.Context) {
|
||||
|
||||
c.Status(http.StatusNoContent)
|
||||
}
|
||||
|
||||
func postServerCompressFiles(c *gin.Context) {
|
||||
s := GetServer(c.Param("server"))
|
||||
|
||||
var data struct {
|
||||
RootPath string `json:"root"`
|
||||
Paths []string `json:"paths"`
|
||||
}
|
||||
|
||||
if err := c.BindJSON(&data); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
f, err := s.Filesystem.CompressFiles(data.RootPath, data.Paths)
|
||||
if err != nil {
|
||||
TrackedServerError(err, s).AbortWithServerError(c)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, &server.Stat{
|
||||
Info: f,
|
||||
Mimetype: "application/tar+gzip",
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user