add share path

This commit is contained in:
kandrusyak
2023-06-30 19:08:44 +03:00
parent b25eaf481f
commit 36a64f4fe3
3 changed files with 8 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ import (
type ServerConfig struct {
Port string
SharePath string
}
type Config struct {
@@ -16,6 +17,7 @@ func New() *Config {
return &Config{
Server: ServerConfig{
Port: getEnv("PORT", ""),
SharePath: getEnv("SHARE_PATH", "public"),
},
}
}

View File

@@ -27,6 +27,8 @@ spec:
value: Europe/Moscow
- name: PORT
value: {{ .Values.app.server.port | quote }}
- name: SHARE_PATH
value: /app/public
image: {{ .Values.app.image }}:{{ .Chart.AppVersion }} #"docker-registry.dopcore.com/andrusyakka/urban-couscous:latest"
imagePullPolicy: Always

View File

@@ -29,7 +29,7 @@ func upload(c echo.Context) error {
uuid := uuid2.New().String()
fileName := uuid + "-" + file.Filename
dst, err := os.Create("public/" + fileName)
dst, err := os.Create(config.Env.Server.SharePath + "/" + fileName)
if err != nil {
return err
}
@@ -51,7 +51,7 @@ func main() {
e.Use(middleware.Logger())
e.Use(middleware.Recover())
e.Static("/", "public")
e.Static("/", config.Env.Server.SharePath)
e.POST("/upload", upload)
e.Logger.Fatal(e.Start(":" + config.Env.Server.Port))