Skins in game + Save user settings to local file
This commit is contained in:
parent
72b5ace984
commit
0222b4fbcc
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -11,4 +11,5 @@
|
|||
tmp
|
||||
config.ini
|
||||
|
||||
hide_*
|
||||
hide_*
|
||||
UserStorage
|
|
@ -144,13 +144,78 @@ func GetCloudStorageFile(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
func GetUserStorageFiles(c *fiber.Ctx) error {
|
||||
return c.Status(fiber.StatusOK).JSON([]aid.JSON{})
|
||||
basePath := "UserStorage/" + c.Params("accountId") + "/"
|
||||
if _, err := os.Stat(basePath); os.IsNotExist(err) {
|
||||
if err := os.MkdirAll(basePath, 0755); err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(aid.ErrorInternalServer)
|
||||
}
|
||||
} else {
|
||||
filePath := basePath
|
||||
fileContent, err := os.ReadFile(filePath + "ClientSettings.Sav")
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusOK).JSON(aid.JSON{})
|
||||
}
|
||||
settingsHash := sha1.Sum(fileContent)
|
||||
settingsHash256 := sha1.Sum(fileContent)
|
||||
return c.Status(fiber.StatusOK).JSON(aid.JSON{
|
||||
"uniqueFilename": "ClientSettings.Sav",
|
||||
"filename": "ClientSettings.Sav",
|
||||
"hash": hex.EncodeToString(settingsHash[:]),
|
||||
"hash256": hex.EncodeToString(settingsHash256[:]),
|
||||
"length": len(fileContent),
|
||||
"contentType": "application/octet-stream",
|
||||
"uploaded": "2021-01-01T00:00:00.000Z",
|
||||
"storageType": "S3",
|
||||
"doNotCache": false,
|
||||
"storageIds": []string{"primary"},
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(aid.JSON{})
|
||||
}
|
||||
|
||||
func GetUserStorageFile(c *fiber.Ctx) error {
|
||||
return c.Status(fiber.StatusOK).JSON(aid.JSON{})
|
||||
basePath := "UserStorage/" + c.Params("accountId") + "/"
|
||||
if _, err := os.Stat(basePath); os.IsNotExist(err) {
|
||||
if err := os.MkdirAll(basePath, 0755); err != nil {
|
||||
return c.Status(fiber.StatusOK).JSON(aid.JSON{})
|
||||
}
|
||||
} else {
|
||||
filePath := basePath + c.Params("fileName")
|
||||
_, err := os.Stat(filePath)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(aid.ErrorNotFound)
|
||||
} else {
|
||||
return c.Status(fiber.StatusOK).SendFile(filePath)
|
||||
}
|
||||
|
||||
}
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(aid.ErrorInternalServer)
|
||||
}
|
||||
|
||||
func PutUserStorageFile(c *fiber.Ctx) error {
|
||||
bytes := string(c.BodyRaw())
|
||||
|
||||
if c.Request().Header.ContentLength() > 400000 || strings.ToLower(c.Params("fileName")) != "clientsettings.sav" {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(aid.ErrorBadRequest("Invalid File"))
|
||||
}
|
||||
|
||||
filePath := "UserStorage/" + c.Params("accountId") + "/"
|
||||
if _, err := os.Stat(filePath); os.IsNotExist(err) {
|
||||
if err := os.MkdirAll(filePath, 0755); err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(aid.ErrorInternalServer)
|
||||
}
|
||||
}
|
||||
|
||||
file, err := os.Create(filePath + c.Params("fileName"))
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(aid.ErrorInternalServer)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
_, err = io.Copy(file, strings.NewReader(bytes))
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(aid.ErrorInternalServer)
|
||||
}
|
||||
|
||||
return c.Status(fiber.StatusOK).JSON(aid.JSON{})
|
||||
}
|
||||
}
|
||||
|
|
3
main.go
3
main.go
|
@ -108,6 +108,7 @@ func main() {
|
|||
profile := game.Group("/profile/:accountId")
|
||||
profile.Use(handlers.MiddlewareFortnite)
|
||||
profile.Post("/client/:action", handlers.PostProfileAction)
|
||||
profile.Post("/dedicated_server/:action", handlers.PostProfileAction)
|
||||
|
||||
lightswitch := r.Group("/lightswitch/api")
|
||||
lightswitch.Use(handlers.MiddlewareFortnite)
|
||||
|
@ -136,4 +137,4 @@ func main() {
|
|||
if err != nil {
|
||||
panic(fmt.Sprintf("Failed to listen: %v", err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user