2023-11-03 23:48:50 +00:00
|
|
|
package handlers
|
|
|
|
|
|
|
|
import (
|
2024-01-04 19:02:14 +00:00
|
|
|
"crypto/sha1"
|
|
|
|
"crypto/sha256"
|
|
|
|
"encoding/hex"
|
|
|
|
|
2023-11-03 23:48:50 +00:00
|
|
|
"github.com/ectrc/snow/aid"
|
2024-01-04 19:02:14 +00:00
|
|
|
"github.com/ectrc/snow/storage"
|
2023-11-03 23:48:50 +00:00
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
func GetCloudStorageFiles(c *fiber.Ctx) error {
|
2024-01-04 19:02:14 +00:00
|
|
|
sum := sha1.Sum(storage.GetDefaultEngine())
|
|
|
|
more := sha256.Sum256(storage.GetDefaultEngine())
|
|
|
|
|
2024-01-20 01:58:57 +00:00
|
|
|
return c.Status(fiber.StatusOK).JSON([]fiber.Map{
|
2024-01-04 19:02:14 +00:00
|
|
|
{
|
|
|
|
"uniqueFilename": "DefaultEngine.ini",
|
|
|
|
"filename": "DefaultEngine.ini",
|
|
|
|
"hash": hex.EncodeToString(sum[:]),
|
|
|
|
"hash256": hex.EncodeToString(more[:]),
|
|
|
|
"length": len(storage.GetDefaultEngine()),
|
|
|
|
"contentType": "application/octet-stream",
|
2024-01-20 01:58:57 +00:00
|
|
|
"uploaded": aid.TimeStartOfDay(),
|
2024-01-04 19:02:14 +00:00
|
|
|
"storageType": "S3",
|
2024-01-20 01:58:57 +00:00
|
|
|
"storageIds": fiber.Map{
|
|
|
|
"primary": "primary",
|
|
|
|
},
|
2024-01-04 19:02:14 +00:00
|
|
|
"doNotCache": false,
|
|
|
|
},
|
|
|
|
})
|
2023-11-03 23:48:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func GetCloudStorageConfig(c *fiber.Ctx) error {
|
2024-01-20 01:58:57 +00:00
|
|
|
return c.Status(fiber.StatusOK).JSON(fiber.Map{
|
2023-11-03 23:48:50 +00:00
|
|
|
"enumerateFilesPath": "/api/cloudstorage/system",
|
2023-12-27 04:35:12 +00:00
|
|
|
"enableMigration": true,
|
|
|
|
"enableWrites": true,
|
|
|
|
"epicAppName": "Live",
|
|
|
|
"isAuthenticated": true,
|
|
|
|
"disableV2": true,
|
2024-01-20 01:58:57 +00:00
|
|
|
"lastUpdated": aid.TimeStartOfDay(),
|
2023-12-27 04:35:12 +00:00
|
|
|
"transports": []string{},
|
2023-11-03 23:48:50 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetCloudStorageFile(c *fiber.Ctx) error {
|
2024-01-04 19:02:14 +00:00
|
|
|
switch c.Params("fileName") {
|
|
|
|
case "DefaultEngine.ini":
|
2024-01-20 01:58:57 +00:00
|
|
|
c.Set("Content-Type", "application/octet-stream")
|
|
|
|
c.Status(fiber.StatusOK)
|
|
|
|
c.Send(storage.GetDefaultEngine())
|
|
|
|
return nil
|
2024-01-04 19:02:14 +00:00
|
|
|
}
|
|
|
|
|
2024-01-03 23:49:40 +00:00
|
|
|
return c.Status(400).JSON(aid.ErrorBadRequest)
|
2023-11-05 01:58:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func GetUserStorageFiles(c *fiber.Ctx) error {
|
2024-01-03 23:49:40 +00:00
|
|
|
return c.Status(200).JSON([]aid.JSON{})
|
2023-11-05 01:58:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func GetUserStorageFile(c *fiber.Ctx) error {
|
2024-01-03 23:49:40 +00:00
|
|
|
return c.Status(200).JSON(aid.JSON{})
|
2023-11-05 01:58:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func PutUserStorageFile(c *fiber.Ctx) error {
|
2024-01-03 23:49:40 +00:00
|
|
|
return c.Status(200).JSON(aid.JSON{})
|
2023-12-27 04:15:26 +00:00
|
|
|
}
|