Compare commits

...

16 Commits

10 changed files with 69 additions and 73 deletions
-5
View File
@@ -1,5 +0,0 @@
# HTTP Settings
PORT=8080
# App Settings
STORAGE_PATH=files
+3 -4
View File
@@ -9,16 +9,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- v1.1 German Translation -
### Changed ### Changed
- Use frontmatter title & description in each language version template -
### Removed ### Removed
- Trademark sign previously shown after the project description in version -
0.3.0
## [0.0.0] - 2000-01-01 ## [0.0.0] - 2000-01-01
+3
View File
@@ -9,3 +9,6 @@ vet: fmt
build: vet build: vet
go build -o drogobox internal/app/main.go go build -o drogobox internal/app/main.go
test:
go test ./tests/...
View File
View File
+2 -4
View File
@@ -1,5 +1,3 @@
module drogobox.com/drogobox module drogobox.com/drogobox-server
go 1.25.9 go 1.26.3
require github.com/joho/godotenv v1.5.1 // indirect
-2
View File
@@ -1,2 +0,0 @@
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
-58
View File
@@ -1,58 +0,0 @@
package main
import (
"fmt"
"log"
"os"
"github.com/joho/godotenv"
)
func resolveFileStorePath(file_store_path string) {
err := os.MkdirAll(file_store_path, os.ModePerm)
if err != nil {
log.Fatal(err)
}
}
type StoredFileNode struct {
Name string `json:"name"` // full file name with extension
Path string `json:"path"` // path to file
Size int64 `json:"size"` // byte size of file
Extension string `json:"extension"` // the file name extension
MimeType string `json:"mime_type"` // mime type regarless of extension
Permissions string `json:"permissions"` // UNIX permissions
IsFolder bool `json:"is_folder"` // directory flag
Modified time.Time `json:"modified_at"` // last modification date
}
func readFilesFromFileStorePath(file_store_path string) {
files, err := os.ReadDir(file_store_path)
if err != nil {
log.Fatal(err)
}
for _, file := range files {
if !file.IsDir() {
fmt.Println(file.Name())
}
}
}
func main() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
port := os.Getenv("PORT")
file_store_path := os.Getenv("STORAGE_PATH")
resolveFileStorePath(file_store_path)
fmt.Printf("in the future I will listen on port: %s\n", port)
fmt.Printf("Reading files from: %s\n", file_store_path)
readFilesFromFileStorePath(file_store_path)
}
+38
View File
@@ -0,0 +1,38 @@
package storage
import (
"io"
"os"
)
type LocalStorage struct {
BaseDir string
}
func (s *LocalStorage) UploadFile(dirPath string, filename string, data io.Reader) error {
//
}
func (s *LocalStorage) ListFiles(dirPath string) ([]FileNode, error) {
//
}
func (s *LocalStorage) ReadFile(filePath string) (*os.File, error) {
//
}
func (s *LocalStorage) WriteFile(dirPath string, filename string, data io.Reader) (int, error) {
// this is explicitly for writing text files that aren't being uploaded
}
func (s *LocalStorage) DeleteFile(filePath string) error {
//
}
func (s *LocalStorage) DeleteDirectory(dirPath string) error {
//
}
func (s *LocalStorage) DeleteDirectoryRecursive(dirPath string) error {
//
}
+23
View File
@@ -0,0 +1,23 @@
package storage
import (
"io"
"os"
)
type Storage interface {
UploadFile(dirPath string, filename string, data io.Reader) error
ListFiles(dirPath string) ([]FileNode, error)
ReadFile(filePath string) (*os.File, error)
WriteFile(dirPath string, filename string, data io.Reader) (int, error)
DeleteFile(filePath string) error
DeleteDirectory(dirPath string) error
DeleteDirectoryRecursive(dirPath string) error
}
type FileNode struct {
RelativeBasePath string
FileName string
IsDirectory bool
FileSize uint64
}