Skip to content

Commit

Permalink
transitive commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pandadiestro committed Nov 23, 2024
1 parent 1befeec commit d446902
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions stiller-backend/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,24 @@ type ConfigType struct {
DBPath string
Secret []byte
Admin string
Host string
FileBucket string
BCryptCost int
}

func newConfig() *ConfigType {
dotenv.Load()

hostname := dotenv.GetString("Host")
return &ConfigType{
Addr: dotenv.GetString("Addr"),
FilesPath: dotenv.GetString("FilesPath"),
DBPath: dotenv.GetString("DBPath"),
Secret: []byte(dotenv.GetString("Secret")),
BCryptCost: dotenv.GetInt("BCryptCost"),
Admin: dotenv.GetString("Admin"),
Host: hostname,
FileBucket: hostname + "file/dl/",
}
}

Expand Down
2 changes: 2 additions & 0 deletions stiller-backend/internal/handlers/file/filedl/handler.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package filedl

import (
"log"
"net/http"
"stiller/internal/dbutils"
"stiller/internal/fsutils"
Expand Down Expand Up @@ -67,6 +68,7 @@ func Nethandler(w http.ResponseWriter, r *http.Request, params httprouter.Params
handleutils.GenericLog(nil, "path '%s' doesnt exist", path)
}

log.Println(path)
http.ServeFile(w, r, path)
}

2 changes: 1 addition & 1 deletion stiller-backend/internal/handlers/file/filetree/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func Nethandler(w http.ResponseWriter, r *http.Request, params httprouter.Params
Id: new_id,
OwnerId: int(stmt.GetInt64("owner")),
Typeof: dbutils.StillerFileType(stmt.GetInt64("type")),
Url: "https://pandadiestro.xyz/services/stiller/file/dl/" + strconv.Itoa(new_id),
Url: stiller.StillerConfig.FileBucket + strconv.Itoa(new_id),
Path: stmt.GetText("path"),
Filename: stmt.GetText("filename"),
Title: stmt.GetText("title"),
Expand Down
2 changes: 1 addition & 1 deletion stiller-backend/internal/handlers/file/upload/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func NetHandler(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
return
}

new_file.Url = "https://pandadiestro.xyz/services/stiller/file/dl/" + strconv.Itoa(new_file.Id)
new_file.Url = stiller.StillerConfig.FileBucket + strconv.Itoa(new_file.Id)

w.WriteHeader(http.StatusOK)
jsonexp.MarshalWrite(w, new_file, jsonexp.DefaultOptionsV2())
Expand Down

0 comments on commit d446902

Please sign in to comment.